Tizen 2.0 Release
[external/tizen-coreutils.git] / build-aux / vc-list-files
1 #!/bin/sh
2 # List the specified version-controlled files.
3
4 # Copyright (C) 2006, 2007 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20
21 # List the specified version-controlled files.
22 # With no argument, list them all.
23 # This script must be run solely from the top of a $srcdir build directory.
24
25 # If there's an argument, it must be a single, "."-relative directory name,
26 # with no trailing slashes.  In mercurial mode, it's used as part of a
27 # "grep" pattern (prepend "^", append "/"), and in cvs mode, it's simply
28 # used as an argument to the cvsu script.
29 # cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
30
31 include_prefix=
32 case $# in
33   0) ;;
34   1) include_prefix=$1 ;;
35   *) echo "$0: too many arguments" 1>&2; exit 1 ;;
36 esac
37
38 if test -d .git; then
39   if test "x$include_prefix" = x; then
40     git-ls-files
41   else
42     git-ls-files | grep "^$include_prefix/"
43   fi
44 elif test -d .hg; then
45   if test "x$include_prefix" = x; then
46     hg manifest | cut -d ' ' -f 2
47   else
48     hg manifest | cut -d ' ' -f 2 | grep "^$include_prefix/"
49   fi
50 elif test -x build-aux/cvsu; then
51   build-aux/cvsu --find --types=AFGM $include_prefix
52 else
53   awk -F/ '{                            \
54       if (!$1 && $3 !~ /^-/) {          \
55         f=FILENAME;                     \
56         sub(/CVS\/Entries/, "", f);     \
57         print f $2;                     \
58       }}'                               \
59     $(find ${*-*} -name Entries -print) /dev/null;
60 fi