X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-am.sh;h=38841d9beec8b718bf0ef4d2b98078783061b57a;hb=a52e4ef877f693a69710145f56d867365a755f91;hp=51ea168e03b0d1e4a906f5f17ead431ca3884502;hpb=4ae22d96fe9248dac4f26b1fc91154ba5e879799;p=git.git diff --git a/git-am.sh b/git-am.sh index 51ea168e..38841d9b 100755 --- a/git-am.sh +++ b/git-am.sh @@ -153,6 +153,7 @@ if test -d "$dotest" then test ",$#," = ",0," || die "previous dotest directory $dotest still exists but mbox given." + resume=yes else # Make sure we are not given --skip test ",$skip," = ,, || @@ -215,32 +216,41 @@ do go_next continue } - git-mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \ - <"$dotest/$msgnum" >"$dotest/info" || - stop_here $this - git-stripspace < "$dotest/msg" > "$dotest/msg-clean" + case "$resume" in + '') + git-mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \ + <"$dotest/$msgnum" >"$dotest/info" || + stop_here $this + git-stripspace < "$dotest/msg" > "$dotest/msg-clean" + ;; + esac GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")" GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")" GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")" - SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")" export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE + SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")" case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac - if test '' != "$SIGNOFF" - then + + case "$resume" in + '') + if test '' != "$SIGNOFF" + then LAST_SIGNED_OFF_BY=` - sed -ne '/^Signed-off-by: /p' "$dotest/msg-clean" | - tail -n 1 + sed -ne '/^Signed-off-by: /p' \ + "$dotest/msg-clean" | + tail -n 1 ` - ADD_SIGNOFF=$(test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { + ADD_SIGNOFF=` + test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { test '' = "$LAST_SIGNED_OFF_BY" && echo echo "$SIGNOFF" - }) - else + }` + else ADD_SIGNOFF= - fi - { + fi + { echo "$SUBJECT" if test -s "$dotest/msg-clean" then @@ -251,8 +261,11 @@ do then echo "$ADD_SIGNOFF" fi - } >"$dotest/final-commit" + } >"$dotest/final-commit" + ;; + esac + resume= if test "$interactive" = t then test -t 0 || @@ -264,14 +277,17 @@ do echo "--------------------------" cat "$dotest/final-commit" echo "--------------------------" - echo -n "Apply? [y]es/[n]o/[e]dit/[a]ccept all " + echo -n "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all " read reply case "$reply" in - y*|Y*) action=yes ;; - a*|A*) action=yes interactive= ;; - n*|N*) action=skip ;; - e*|E*) "${VISUAL:-${EDITOR:-vi}}" "$dotest/final-commit" + [yY]*) action=yes ;; + [aA]*) action=yes interactive= ;; + [nN]*) action=skip ;; + [eE]*) "${VISUAL:-${EDITOR:-vi}}" "$dotest/final-commit" action=again ;; + [vV]*) action=again + LESS=-S ${PAGER:-less} "$dotest/patch" ;; + *) action=again ;; esac done else