Code

git-grep: don't use sscanf
[git.git] / git-am.sh
index 59d663ba9e0c3828d11b442c6fd9536a87d937cb..2c73d116b28d0d89d1fbdfc1d454506bff9e3f46 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -3,10 +3,11 @@
 # Copyright (c) 2005, 2006 Junio C Hamano
 
 USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
-  [--interactive] [--whitespace=<option>] <mbox>...
+  [--interactive] [--whitespace=<option>] [-C<n>] [-p<n>] <mbox>...
   or, when resuming [--skip | --resolved]'
 . git-sh-setup
 set_reflog_action am
+require_work_tree
 
 git var GIT_COMMITTER_IDENT >/dev/null || exit
 
@@ -65,7 +66,7 @@ fall_back_3way () {
     git-update-index -z --index-info <"$dotest/patch-merge-index-info" &&
     GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
     git-write-tree >"$dotest/patch-merge-base+" ||
-    cannot_fallback "Patch does not record usable index information."
+    cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."
 
     echo Using index info to reconstruct a base tree...
     if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
@@ -105,7 +106,8 @@ It does not apply to blobs recorded in its index."
 }
 
 prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg=
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=
+git_apply_opt=
 
 while case "$#" in 0) break;; esac
 do
@@ -140,8 +142,8 @@ do
        --sk|--ski|--skip)
        skip=t; shift ;;
 
-       --whitespace=*)
-       ws=$1; shift ;;
+       --whitespace=*|-C*|-p*)
+       git_apply_opt="$git_apply_opt $1"; shift ;;
 
        --resolvemsg=*)
        resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
@@ -393,7 +395,7 @@ do
 
        case "$resolved" in
        '')
-               git-apply $binary --index $ws "$dotest/patch"
+               git-apply $git_apply_opt $binary --index "$dotest/patch"
                apply_status=$?
                ;;
        t)