Blame build-aux/vc-list-files

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