git-add.shon commit [PATCH] allow merging any committish (9954f5b)
   1#!/bin/sh
   2
   3die () {
   4    echo >&2 "$*"
   5    exit 1
   6}
   7
   8usage() {
   9    die "usage: git add [-n] [-v] <file>..."
  10}
  11
  12show_only=
  13verbose=
  14while : ; do
  15  case "$1" in
  16    -n)
  17        show_only=true
  18        ;;
  19    -v)
  20        verbose=--verbose
  21        ;;
  22    -*)
  23        usage
  24        ;;
  25    *)
  26        break
  27        ;;
  28  esac
  29  shift
  30done
  31
  32GIT_DIR=$(git-rev-parse --git-dir) || exit
  33
  34if test -f "$GIT_DIR/info/exclude"
  35then
  36        git-ls-files -z \
  37        --exclude-from="$GIT_DIR/info/exclude" \
  38        --others --exclude-per-directory=.gitignore -- "$@"
  39else
  40        git-ls-files -z \
  41        --others --exclude-per-directory=.gitignore -- "$@"
  42fi |
  43case "$show_only" in
  44true)
  45        xargs -0 echo ;;
  46*)
  47        git-update-index --add $verbose -z --stdin ;;
  48esac