X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-am.sh;h=1056075545ad3e5e42626d167c91c1deada6186b;hb=c30c10cff1d640ce119596b907c10cc11f83358d;hp=dc8d242beb473410087f237136958116c0d09339;hpb=ad2c928001d2d94f2cbf3c75734061eb8fc4383c;p=git.git diff --git a/git-am.sh b/git-am.sh index dc8d242be..105607554 100755 --- a/git-am.sh +++ b/git-am.sh @@ -16,6 +16,7 @@ s,signoff add a Signed-off-by line to the commit message u,utf8 recode into utf8 (default) k,keep pass -k flag to git-mailinfo keep-cr pass --keep-cr flag to git-mailsplit for mbox format +no-keep-cr do not pass --keep-cr flag to git-mailsplit independent of am.keepcr c,scissors strip everything before a scissors line whitespace= pass it through git-apply ignore-space-change pass it through git-apply @@ -218,7 +219,7 @@ check_patch_format () { split_patches () { case "$patch_format" in mbox) - if test -n "$rebasing$keepcr" + if test -n "$rebasing" || test t = "$keepcr" then keep_cr=--keep-cr else @@ -299,6 +300,11 @@ committer_date_is_author_date= ignore_date= allow_rerere_autoupdate= +if test "$(git config --bool --get am.keepcr)" = true +then + keepcr=t +fi + while test $# != 0 do case "$1" in @@ -351,6 +357,8 @@ do GIT_QUIET=t ;; --keep-cr) keepcr=t ;; + --no-keep-cr) + keepcr=f ;; --) shift; break ;; *) @@ -500,10 +508,12 @@ if test "$(cat "$dotest/keep")" = t then keep=-k fi -if test "$(cat "$dotest/keepcr")" = t -then - keepcr=--keep-cr -fi +case "$(cat "$dotest/keepcr")" in +t) + keepcr=--keep-cr ;; +f) + keepcr=--no-keep-cr ;; +esac case "$(cat "$dotest/scissors")" in t) scissors=--scissors ;; @@ -583,6 +593,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") && @@ -590,6 +601,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" @@ -671,10 +683,7 @@ do [eE]*) git_editor "$dotest/final-commit" action=again ;; [vV]*) action=again - : ${GIT_PAGER=$(git var GIT_PAGER)} - : ${LESS=-FRSX} - export LESS - $GIT_PAGER "$dotest/patch" ;; + git_pager "$dotest/patch" ;; *) action=again ;; esac done @@ -776,6 +785,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 @@ -784,5 +797,12 @@ do go_next done +if test -s "$dotest"/rewritten; then + git notes copy --for-rewrite=rebase < "$dotest"/rewritten + if test -x "$GIT_DIR"/hooks/post-rewrite; then + "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten + fi +fi + rm -fr "$dotest" git gc --auto