git-rm.shon commit Merge branch 'jc/tartree' into jc/builtin-n-tar-tree (1af0d11)
   1#!/bin/sh
   2
   3USAGE='[-f] [-n] [-v] [--] <file>...'
   4SUBDIRECTORY_OK='Yes'
   5. git-sh-setup
   6
   7remove_files=
   8show_only=
   9verbose=
  10while : ; do
  11  case "$1" in
  12    -f)
  13        remove_files=true
  14        ;;
  15    -n)
  16        show_only=true
  17        ;;
  18    -v)
  19        verbose=--verbose
  20        ;;
  21    --)
  22        shift; break
  23        ;;
  24    -*)
  25        usage
  26        ;;
  27    *)
  28        break
  29        ;;
  30  esac
  31  shift
  32done
  33
  34# This is typo-proofing. If some paths match and some do not, we want
  35# to do nothing.
  36case "$#" in
  370)      ;;
  38*)
  39        git-ls-files --error-unmatch -- "$@" >/dev/null || {
  40                echo >&2 "Maybe you misspelled it?"
  41                exit 1
  42        }
  43        ;;
  44esac
  45
  46if test -f "$GIT_DIR/info/exclude"
  47then
  48        git-ls-files -z \
  49        --exclude-from="$GIT_DIR/info/exclude" \
  50        --exclude-per-directory=.gitignore -- "$@"
  51else
  52        git-ls-files -z \
  53        --exclude-per-directory=.gitignore -- "$@"
  54fi |
  55case "$show_only,$remove_files" in
  56true,*)
  57        xargs -0 echo
  58        ;;
  59*,true)
  60        xargs -0 sh -c "
  61                while [ \$# -gt 0 ]; do
  62                        file=\$1; shift
  63                        rm -- \"\$file\" && git-update-index --remove $verbose \"\$file\"
  64                done
  65        " inline
  66        ;;
  67*)
  68        git-update-index --force-remove $verbose -z --stdin
  69        ;;
  70esac