Add Gnulib maintainer modules.
[bpt/guile.git] / build-aux / vc-list-files
CommitLineData
c84bdaf6
LC
1#!/bin/sh
2# List version-controlled file names.
3
4# Print a version string.
5scriptversion=2009-07-21.16; # UTC
6
7# Copyright (C) 2006-2009 Free Software Foundation, Inc.
8
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.
13
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.
18
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22
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.
26
27# If there's an argument, it must be a single, "."-relative directory name.
28# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
29
30postprocess=
31case $1 in
32 --help) cat <<EOF
33Usage: $0 [-C SRCDIR] [DIR]
34
35Output a list of version-controlled files in DIR (default .), relative to
36SRCDIR (default .). SRCDIR must be the top directory of a checkout.
37
38Options:
39 --help print this help, then exit
40 --version print version number, then exit
41 -C SRCDIR change directory to SRCDIR before generating list
42
43Report bugs and patches to <bug-gnulib@gnu.org>.
44EOF
45 exit ;;
46
47 --version)
48 year=`echo "$scriptversion" | sed 's/[^0-9].*//'`
49 cat <<EOF
50vc-list-files $scriptversion
51Copyright (C) $year Free Software Foundation, Inc,
52License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
53This is free software: you are free to change and redistribute it.
54There is NO WARRANTY, to the extent permitted by law.
55EOF
56 exit ;;
57
58 -C)
59 test "$2" = . || postprocess="| sed 's|^|$2/|'"
60 cd "$2" || exit 1
61 shift; shift ;;
62esac
63
64dir=
65case $# in
66 0) ;;
67 1) dir=$1 ;;
68 *) echo "$0: too many arguments" 1>&2
69 echo "Usage: $0 [-C srcdir] [DIR]" 1>&2; exit 1;;
70esac
71
72test "x$dir" = x && dir=.
73
74if test -d .git; then
75 test "x$dir" = x. \
76 && dir= sed_esc= \
77 || { dir="$dir/"; sed_esc=`echo "$dir"|env sed 's,\([\\/]\),\\\\\1,g'`; }
78 # Ignore git symlinks - either they point into the tree, in which case
79 # we don't need to visit the target twice, or they point somewhere
80 # else (often into a submodule), in which case the content does not
81 # belong to this package.
82 eval exec git ls-tree -r 'HEAD:"$dir"' \
83 \| sed -n '"s/^100[^ ]*./$sed_esc/p"' $postprocess
84elif test -d .hg; then
85 eval exec hg locate '"$dir/*"' $postprocess
86elif test -d .bzr; then
87 test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
88 eval exec bzr ls --versioned '"$dir"' $postprocess
89elif test -d CVS; then
90 test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
91 if test -x build-aux/cvsu; then
92 eval build-aux/cvsu --find --types=AFGM '"$dir"' $postprocess
93 elif (cvsu --help) >/dev/null 2>&1; then
94 eval cvsu --find --types=AFGM '"$dir"' $postprocess
95 else
96 eval awk -F/ \''{ \
97 if (!$1 && $3 !~ /^-/) { \
98 f=FILENAME; \
99 if (f ~ /CVS\/Entries$/) \
100 f = substr(f, 1, length(f)-11); \
101 print f $2; \
102 }}'\'' \
103 `find "$dir" -name Entries -print` /dev/null' $postprocess
104 fi
105else
106 echo "$0: Failed to determine type of version control used in `pwd`" 1>&2
107 exit 1
108fi
109
110# Local variables:
111# eval: (add-hook 'write-file-hooks 'time-stamp)
112# time-stamp-start: "scriptversion="
113# time-stamp-format: "%:y-%02m-%02d.%02H"
114# time-stamp-time-zone: "UTC"
115# time-stamp-end: "; # UTC"
116# End: