am --rebasing: get patch body from commit, not from mailbox
[gitweb.git] / git-am.sh
index 4da0ddafc4bf2029823148e7285085661c134497..ec8fde102cabc50bff43c8862cf001616636d4ad 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -24,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
@@ -138,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
@@ -412,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 ;;
@@ -676,6 +683,7 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."
                        sed -e '1,/^$/d' >"$dotest/msg-clean"
                        echo "$commit" > "$dotest/original-commit"
                        get_author_ident_from_commit "$commit" > "$dotest/author-script"
+                       git diff-tree --root --binary "$commit" >"$dotest/patch"
                else
                        {
                                sed -n '/^Subject/ s/Subject: //p' "$dotest/info"