c7c4dbdaf122b07262221ba4192bda5162409885
[platform/upstream/coreutils.git] / build-aux / vc-list-files
1 #!/bin/sh
2 # List the specified version-controlled files.
3 # With no argument, list them all.
4 # This script must be run solely from the top of a $srcdir build directory.
5
6 # If there's an argument, it must be a single, "."-relative directory name,
7 # with no trailing slashes.  In mercurial mode, it's used as part of a
8 # "grep" pattern (prepend "^", append "/"), and in cvs mode, it's simply
9 # used as an argument to the cvsu script.
10
11 include_prefix=
12 case $# in
13   0) ;;
14   1) include_prefix=$1 ;;
15   *) echo "$0: too many arguments" 1>&2; exit 1 ;;
16 esac
17
18 if test -d .git; then
19   if test "x$include_prefix" = x; then
20     git-ls-files | cut -d ' ' -f 3
21   else
22     git-ls-files | cut -d ' ' -f 3 | grep "^$include_prefix/"
23   fi
24 elif test -d .hg; then
25   if test "x$include_prefix" = x; then
26     hg manifest | cut -d ' ' -f 3
27   else
28     hg manifest | cut -d ' ' -f 3 | grep "^$include_prefix/"
29   fi
30 elif test -x build-aux/cvsu; then
31   build-aux/cvsu --find --types=AFGM $include_prefix
32 else
33   awk -F/ '{                            \
34       if (!$1 && $3 !~ /^-/) {          \
35         f=FILENAME;                     \
36         sub(/CVS\/Entries/, "", f);     \
37         print f $2;                     \
38       }}'                               \
39     $(find ${*-*} -name Entries -print) /dev/null;
40 fi