Blame build-aux/vc-list-files

Packit 549fdc
#!/bin/sh
Packit 549fdc
# List version-controlled file names.
Packit 549fdc
Packit 549fdc
# Print a version string.
Packit 549fdc
scriptversion=2016-01-11.22; # UTC
Packit 549fdc
Packit 549fdc
# Copyright (C) 2006-2016 Free Software Foundation, Inc.
Packit 549fdc
Packit 549fdc
# This program is free software: you can redistribute it and/or modify
Packit 549fdc
# it under the terms of the GNU General Public License as published by
Packit 549fdc
# the Free Software Foundation, either version 3 of the License, or
Packit 549fdc
# (at your option) any later version.
Packit 549fdc
Packit 549fdc
# This program is distributed in the hope that it will be useful,
Packit 549fdc
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 549fdc
# GNU General Public License for more details.
Packit 549fdc
Packit 549fdc
# You should have received a copy of the GNU General Public License
Packit 549fdc
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 549fdc
Packit 549fdc
Packit 549fdc
# List the specified version-controlled files.
Packit 549fdc
# With no argument, list them all.  With a single DIRECTORY argument,
Packit 549fdc
# list the version-controlled files in that directory.
Packit 549fdc
Packit 549fdc
# If there's an argument, it must be a single, "."-relative directory name.
Packit 549fdc
# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
Packit 549fdc
Packit 549fdc
postprocess=
Packit 549fdc
case $1 in
Packit 549fdc
  --help) cat <
Packit 549fdc
Usage: $0 [-C SRCDIR] [DIR...]
Packit 549fdc
Packit 549fdc
Output a list of version-controlled files in DIR (default .), relative to
Packit 549fdc
SRCDIR (default .).  SRCDIR must be the top directory of a checkout.
Packit 549fdc
Packit 549fdc
Options:
Packit 549fdc
  --help     print this help, then exit
Packit 549fdc
  --version  print version number, then exit
Packit 549fdc
  -C SRCDIR  change directory to SRCDIR before generating list
Packit 549fdc
Packit 549fdc
Report bugs and patches to <bug-gnulib@gnu.org>.
Packit 549fdc
EOF
Packit 549fdc
    exit ;;
Packit 549fdc
Packit 549fdc
  --version)
Packit 549fdc
    year=`echo "$scriptversion" | sed 's/[^0-9].*//'`
Packit 549fdc
    cat <
Packit 549fdc
vc-list-files $scriptversion
Packit 549fdc
Copyright (C) $year Free Software Foundation, Inc,
Packit 549fdc
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Packit 549fdc
This is free software: you are free to change and redistribute it.
Packit 549fdc
There is NO WARRANTY, to the extent permitted by law.
Packit 549fdc
EOF
Packit 549fdc
    exit ;;
Packit 549fdc
Packit 549fdc
  -C)
Packit 549fdc
    test "$2" = . || postprocess="| sed 's|^|$2/|'"
Packit 549fdc
    cd "$2" || exit 1
Packit 549fdc
    shift; shift ;;
Packit 549fdc
esac
Packit 549fdc
Packit 549fdc
test $# = 0 && set .
Packit 549fdc
Packit 549fdc
for dir
Packit 549fdc
do
Packit 549fdc
  if test -d .git; then
Packit 549fdc
    test "x$dir" = x. \
Packit 549fdc
      && dir= sed_esc= \
Packit 549fdc
      || { dir="$dir/"; sed_esc=`echo "$dir"|env sed 's,\([\\/]\),\\\\\1,g'`; }
Packit 549fdc
    # Ignore git symlinks - either they point into the tree, in which case
Packit 549fdc
    # we don't need to visit the target twice, or they point somewhere
Packit 549fdc
    # else (often into a submodule), in which case the content does not
Packit 549fdc
    # belong to this package.
Packit 549fdc
    eval exec git ls-tree -r 'HEAD:"$dir"' \
Packit 549fdc
      \| sed -n '"s/^100[^	]*./$sed_esc/p"' $postprocess
Packit 549fdc
  elif test -d .hg; then
Packit 549fdc
    eval exec hg locate '"$dir/*"' $postprocess
Packit 549fdc
  elif test -d .bzr; then
Packit 549fdc
    test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
Packit 549fdc
    eval exec bzr ls -R --versioned '"$dir"' $postprocess
Packit 549fdc
  elif test -d CVS; then
Packit 549fdc
    test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
Packit 549fdc
    if test -x build-aux/cvsu; then
Packit 549fdc
      eval build-aux/cvsu --find --types=AFGM '"$dir"' $postprocess
Packit 549fdc
    elif (cvsu --help) >/dev/null 2>&1; then
Packit 549fdc
      eval cvsu --find --types=AFGM '"$dir"' $postprocess
Packit 549fdc
    else
Packit 549fdc
      eval awk -F/ \''{			\
Packit 549fdc
          if (!$1 && $3 !~ /^-/) {	\
Packit 549fdc
            f=FILENAME;			\
Packit 549fdc
            if (f ~ /CVS\/Entries$/)	\
Packit 549fdc
              f = substr(f, 1, length(f)-11); \
Packit 549fdc
            print f $2;			\
Packit 549fdc
          }}'\''				\
Packit 549fdc
        `find "$dir" -name Entries -print` /dev/null' $postprocess
Packit 549fdc
    fi
Packit 549fdc
  elif test -d .svn; then
Packit 549fdc
    eval exec svn list -R '"$dir"' $postprocess
Packit 549fdc
  else
Packit 549fdc
    echo "$0: Failed to determine type of version control used in `pwd`" 1>&2
Packit 549fdc
    exit 1
Packit 549fdc
  fi
Packit 549fdc
done
Packit 549fdc
Packit 549fdc
# Local variables:
Packit 549fdc
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit 549fdc
# time-stamp-start: "scriptversion="
Packit 549fdc
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit 549fdc
# time-stamp-time-zone: "UTC0"
Packit 549fdc
# time-stamp-end: "; # UTC"
Packit 549fdc
# End: