notes: implement helpers needed for note copying during rewrite
[gitweb.git] / git-am.sh
index 2f46fda47bc1aa0a345c5cb7293724497965d75e..1056e7db6bba15112022421e3b3f9e3bdb96919f 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -573,6 +573,7 @@ do
                        echo "Patch is empty.  Was it split wrong?"
                        stop_here $this
                }
+               rm -f "$dotest/original-commit"
                if test -f "$dotest/rebasing" &&
                        commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
                                -e q "$dotest/$msgnum") &&
@@ -580,6 +581,7 @@ do
                then
                        git cat-file commit "$commit" |
                        sed -e '1,/^$/d' >"$dotest/msg-clean"
+                       echo "$commit" > "$dotest/original-commit"
                else
                        {
                                sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
@@ -766,6 +768,10 @@ do
        git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
        stop_here $this
 
+       if test -f "$dotest/original-commit"; then
+               echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
+       fi
+
        if test -x "$GIT_DIR"/hooks/post-applypatch
        then
                "$GIT_DIR"/hooks/post-applypatch
@@ -774,6 +780,10 @@ do
        go_next
 done
 
+if test -s "$dotest"/rewritten && test -x "$GIT_DIR"/hooks/post-rewrite; then
+       "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
+fi
+
 git gc --auto
 
 rm -fr "$dotest"