Fix use of $3 in _AC_FUNC_MALLOC_IF etc
[autoconf.git] / build-aux / vc-list-files
blob7036576405fad7de3a4e689049242fa3fc704555
1 #!/bin/sh
2 # List version-controlled file names.
4 # Print a version string.
5 scriptversion=2018-03-07.03; # UTC
7 # Copyright (C) 2006-2024 Free Software Foundation, Inc.
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <https://www.gnu.org/licenses/>.
23 # List the specified version-controlled files.
24 # With no argument, list them all. With a single DIRECTORY argument,
25 # list the version-controlled files in that directory.
27 # If there's an argument, it must be a single, "."-relative directory name.
28 # cvsu is part of the cvsutils package: https://www.red-bean.com/cvsutils/
30 postprocess=
31 case $1 in
32 --help) cat <<EOF
33 Usage: $0 [-C SRCDIR] [DIR...]
35 Output a list of version-controlled files in DIR (default .), relative to
36 SRCDIR (default .). SRCDIR must be the top directory of a checkout.
38 Options:
39 --help print this help, then exit
40 --version print version number, then exit
41 -C SRCDIR change directory to SRCDIR before generating list
43 Report bugs and patches to <bug-gnulib@gnu.org>.
44 EOF
45 exit ;;
47 --version)
48 year=`echo "$scriptversion" | sed 's/[^0-9].*//'`
49 cat <<EOF
50 vc-list-files $scriptversion
51 Copyright (C) $year Free Software Foundation, Inc,
52 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
53 This is free software: you are free to change and redistribute it.
54 There is NO WARRANTY, to the extent permitted by law.
55 EOF
56 exit ;;
58 -C)
59 test "$2" = . || postprocess="| sed 's|^|$2/|'"
60 cd "$2" || exit 1
61 shift; shift ;;
62 esac
64 test $# = 0 && set .
66 for dir
68 if test -d .git || test -f .git; then
69 test "x$dir" = x. \
70 && dir= sed_esc= \
71 || { dir="$dir/"; sed_esc=`echo "$dir"|env sed 's,\([\\/]\),\\\\\1,g'`; }
72 # Ignore git symlinks - either they point into the tree, in which case
73 # we don't need to visit the target twice, or they point somewhere
74 # else (often into a submodule), in which case the content does not
75 # belong to this package.
76 eval exec git ls-tree -r 'HEAD:"$dir"' \
77 \| sed -n '"s/^100[^ ]*./$sed_esc/p"' $postprocess
78 elif test -d .hg; then
79 eval exec hg locate '"$dir/*"' $postprocess
80 elif test -d .bzr; then
81 test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
82 eval exec bzr ls -R --versioned '"$dir"' $postprocess
83 elif test -d CVS; then
84 test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
85 if test -x build-aux/cvsu; then
86 eval build-aux/cvsu --find --types=AFGM '"$dir"' $postprocess
87 elif (cvsu --help) >/dev/null 2>&1; then
88 eval cvsu --find --types=AFGM '"$dir"' $postprocess
89 else
90 eval awk -F/ \''{ \
91 if (!$1 && $3 !~ /^-/) { \
92 f=FILENAME; \
93 if (f ~ /CVS\/Entries$/) \
94 f = substr(f, 1, length(f)-11); \
95 print f $2; \
96 }}'\'' \
97 `find "$dir" -name Entries -print` /dev/null' $postprocess
99 elif test -d .svn; then
100 eval exec svn list -R '"$dir"' $postprocess
101 else
102 echo "$0: Failed to determine type of version control used in `pwd`" 1>&2
103 exit 1
105 done
107 # Local variables:
108 # eval: (add-hook 'before-save-hook 'time-stamp)
109 # time-stamp-start: "scriptversion="
110 # time-stamp-format: "%:y-%02m-%02d.%02H"
111 # time-stamp-time-zone: "UTC0"
112 # time-stamp-end: "; # UTC"
113 # End: