]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-am.sh
cvsexportcommit: Create config option for CVS dir
[git.git] / git-am.sh
index 245e1db1fc30c9446f42ae6b4626de854062afc7..75886a8f2fb0c2244ba921398ae2339dc9ffea26 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -327,11 +327,20 @@ do
                        echo "Patch is empty.  Was it split wrong?"
                        stop_here $this
                }
-               SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
-               case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
-
-               (echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
-                       git stripspace > "$dotest/msg-clean"
+               if test -f "$dotest/rebasing" &&
+                       commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
+                               -e q "$dotest/$msgnum") &&
+                       test "$(git cat-file -t "$commit")" = commit
+               then
+                       git cat-file commit "$commit" |
+                       sed -e '1,/^$/d' >"$dotest/msg-clean"
+               else
+                       SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
+                       case "$keep_subject" in -k)  SUBJECT="[PATCH] $SUBJECT" ;; esac
+
+                       (printf '%s\n\n' "$SUBJECT"; cat "$dotest/msg") |
+                               git stripspace > "$dotest/msg-clean"
+               fi
                ;;
        esac
 
@@ -383,7 +392,6 @@ do
                        ;;
                esac
        esac
-       FIRSTLINE=$(head -1 "$dotest/final-commit")
 
        resume=
        if test "$interactive" = t
@@ -404,7 +412,6 @@ do
                [aA]*) action=yes interactive= ;;
                [nN]*) action=skip ;;
                [eE]*) git_editor "$dotest/final-commit"
-                      FIRSTLINE=$(head -1 "$dotest/final-commit")
                       action=again ;;
                [vV]*) action=again
                       LESS=-S ${PAGER:-less} "$dotest/patch" ;;
@@ -414,6 +421,7 @@ do
        else
            action=yes
        fi
+       FIRSTLINE=$(head -1 "$dotest/final-commit")
 
        if test $action = skip
        then