Blame build-aux/vc-list-files

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