Merge branch 'pg/maint-1.7.9-am-where-is-patch' into maint
[git.git] / git-am.sh
index f1ae932fa753c7c08769b96420d04fed8ed58804..9abad36abdea89c88d7d0378fd2d556057bc065b 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -15,6 +15,7 @@ q,quiet         be quiet
 s,signoff       add a Signed-off-by line to the commit message
 u,utf8          recode into utf8 (default)
 k,keep          pass -k flag to git-mailinfo
+keep-non-patch  pass -b flag to git-mailinfo
 keep-cr         pass --keep-cr flag to git-mailsplit for mbox format
 no-keep-cr      do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
 c,scissors      strip everything before a scissors line
@@ -23,6 +24,7 @@ ignore-space-change pass it through git-apply
 ignore-whitespace pass it through git-apply
 directory=      pass it through git-apply
 exclude=        pass it through git-apply
+include=        pass it through git-apply
 C=              pass it through git-apply
 p=              pass it through git-apply
 patch-format=   format the patch(es) are in
@@ -137,6 +139,12 @@ fall_back_3way () {
     say Using index info to reconstruct a base tree...
 
     cmd='GIT_INDEX_FILE="$dotest/patch-merge-tmp-index"'
+
+    if test -z "$GIT_QUIET"
+    then
+       eval "$cmd git diff-index --cached --diff-filter=AM --name-status HEAD"
+    fi
+
     cmd="$cmd git apply --cached $git_apply_opt"' <"$dotest/patch"'
     if eval "$cmd"
     then
@@ -379,7 +387,9 @@ do
        -i|--interactive)
                interactive=t ;;
        -b|--binary)
-               : ;;
+               echo >&2 "The $1 option has been a no-op for long time, and"
+               echo >&2 "it will be removed. Please do not use it anymore."
+               ;;
        -3|--3way)
                threeway=t ;;
        -s|--signoff)
@@ -390,6 +400,8 @@ do
                utf8= ;;
        -k|--keep)
                keep=t ;;
+       --keep-non-patch)
+               keep=b ;;
        -c|--scissors)
                scissors=t ;;
        --no-scissors)
@@ -407,7 +419,7 @@ do
                ;;
        --resolvemsg)
                shift; resolvemsg=$1 ;;
-       --whitespace|--directory|--exclude)
+       --whitespace|--directory|--exclude|--include)
                git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
        -C|-p)
                git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
@@ -568,16 +580,25 @@ case "$resolved" in
        fi
 esac
 
+# Now, decide what command line options we will give to the git
+# commands we invoke, based on the result of parsing command line
+# options and previous invocation state stored in $dotest/ files.
+
 if test "$(cat "$dotest/utf8")" = t
 then
        utf8=-u
 else
        utf8=-n
 fi
-if test "$(cat "$dotest/keep")" = t
-then
-       keep=-k
-fi
+keep=$(cat "$dotest/keep")
+case "$keep" in
+t)
+       keep=-k ;;
+b)
+       keep=-b ;;
+*)
+       keep= ;;
+esac
 case "$(cat "$dotest/scissors")" in
 t)
        scissors=--scissors ;;