X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-am.sh;h=04f01194356ea0c91a01eed682b068c15e313ee6;hb=0881d2d1303a067a02e3811d43a1aed04a47945e;hp=33f208cb0b7a7d7bad264b41443a966a567156ff;hpb=94cdb382583e7c87d949fb22754d795a1b956377;p=git.git diff --git a/git-am.sh b/git-am.sh index 33f208cb0..04f011943 100755 --- a/git-am.sh +++ b/git-am.sh @@ -59,46 +59,12 @@ fall_back_3way () { GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ git-write-tree >"$dotest/patch-merge-base+" && # index has the base tree now. - ( - cd "$dotest/patch-merge-tmp-dir" && - GIT_INDEX_FILE="../patch-merge-tmp-index" \ - GIT_OBJECT_DIRECTORY="$O_OBJECT" \ - git-apply $binary --index <../patch - ) + GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ + git-apply $binary --cached <"$dotest/patch" then echo Using index info to reconstruct a base tree... mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base" mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index" - else - # Otherwise, try nearby trees that can be used to apply the - # patch. - ( - N=10 - - # Hoping the patch is against our recent commits... - git-rev-list --max-count=$N HEAD - - # or hoping the patch is against known tags... - git-ls-remote --tags . - ) | - while read base junk - do - # See if we have it as a tree... - git-cat-file tree "$base" >/dev/null 2>&1 || continue - - rm -fr "$dotest"/patch-merge-* && - mkdir "$dotest/patch-merge-tmp-dir" || break - ( - cd "$dotest/patch-merge-tmp-dir" && - GIT_INDEX_FILE=../patch-merge-tmp-index && - GIT_OBJECT_DIRECTORY="$O_OBJECT" && - export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY && - git-read-tree "$base" && - git-apply $binary --index && - mv ../patch-merge-tmp-index ../patch-merge-index && - echo "$base" >../patch-merge-base - ) <"$dotest/patch" 2>/dev/null && break - done fi test -f "$dotest/patch-merge-index" && @@ -111,7 +77,7 @@ fall_back_3way () { # This is not so wrong. Depending on which base we picked, # orig_tree may be wildly different from ours, but his_tree # has the same set of wildly different changes in parts the - # patch did not touch, so resolve ends up cancelling them, + # patch did not touch, so resolve ends up canceling them, # saying that we reverted all those changes. git-merge-resolve $orig_tree -- HEAD $his_tree || { @@ -125,13 +91,14 @@ fall_back_3way () { } prec=4 +rloga=am dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= ws= resolvemsg= while case "$#" in 0) break;; esac do case "$1" in -d=*|--d=*|--do=*|--dot=*|--dote=*|--dotes=*|--dotest=*) - dotest=`expr "$1" : '-[^=]*=\(.*\)'`; shift ;; + dotest=`expr "z$1" : 'z-[^=]*=\(.*\)'`; shift ;; -d|--d|--do|--dot|--dote|--dotes|--dotest) case "$#" in 1) usage ;; esac; shift dotest="$1"; shift;; @@ -164,6 +131,9 @@ do --resolvemsg=*) resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;; + --reflog-action=*) + rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`; shift ;; + --) shift; break ;; -*) @@ -186,8 +156,10 @@ fi if test -d "$dotest" then - test ",$#," = ",0," || - die "previous dotest directory $dotest still exists but mbox given." + if test ",$#," != ",0," || ! tty -s + then + die "previous dotest directory $dotest still exists but mbox given." + fi resume=yes else # Make sure we are not given --skip nor --resolved @@ -447,7 +419,7 @@ do parent=$(git-rev-parse --verify HEAD) && commit=$(git-commit-tree $tree -p $parent <"$dotest/final-commit") && echo Committed: $commit && - git-update-ref HEAD $commit $parent || + git-update-ref -m "$rloga: $SUBJECT" HEAD $commit $parent || stop_here $this if test -x "$GIT_DIR"/hooks/post-applypatch