From: Junio C Hamano Date: Sun, 27 Jun 2010 19:07:44 +0000 (-0700) Subject: Merge branch 'js/maint-am-rebase-invalid-author' X-Git-Tag: v1.7.2-rc0~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/bcdfb20ae94138eac863b4c40263dc10f29917e5?ds=inline;hp=-c Merge branch 'js/maint-am-rebase-invalid-author' * js/maint-am-rebase-invalid-author: am: use get_author_ident_from_commit instead of mailinfo when rebasing --- bcdfb20ae94138eac863b4c40263dc10f29917e5 diff --combined git-am.sh index ef2d51a2b8,abcb05b6ba..e7f008c7ba --- a/git-am.sh +++ b/git-am.sh @@@ -52,16 -52,6 +52,16 @@@ els HAS_HEAD= fi +cmdline="git am" +if test '' != "$interactive" +then + cmdline="$cmdline -i" +fi +if test '' != "$threeway" +then + cmdline="$cmdline -3" +fi + sq () { git rev-parse --sq-quote "$@" } @@@ -76,6 -66,15 +76,6 @@@ stop_here_user_resolve () printf '%s\n' "$resolvemsg" stop_here $1 fi - cmdline="git am" - if test '' != "$interactive" - then - cmdline="$cmdline -i" - fi - if test '' != "$threeway" - then - cmdline="$cmdline -3" - fi echo "When you have resolved this problem run \"$cmdline --resolved\"." echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"." echo "To restore the original branch and stop patching run \"$cmdline --abort\"." @@@ -592,11 -591,9 +592,11 @@@ d test -s "$dotest/patch" || { echo "Patch is empty. Was it split wrong?" + echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"." + echo "To restore the original branch and stop patching run \"$cmdline --abort\"." stop_here $this } - rm -f "$dotest/original-commit" + rm -f "$dotest/original-commit" "$dotest/author-script" if test -f "$dotest/rebasing" && commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \ -e q "$dotest/$msgnum") && @@@ -605,6 -602,7 +605,7 @@@ git cat-file commit "$commit" | sed -e '1,/^$/d' >"$dotest/msg-clean" echo "$commit" > "$dotest/original-commit" + get_author_ident_from_commit "$commit" > "$dotest/author-script" else { sed -n '/^Subject/ s/Subject: //p' "$dotest/info" @@@ -616,9 -614,14 +617,14 @@@ ;; 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")" + if test -f "$dotest/author-script" + then + eval $(cat "$dotest/author-script") + else + 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")" + fi if test -z "$GIT_AUTHOR_EMAIL" then @@@ -693,13 -696,7 +699,13 @@@ else action=yes fi - FIRSTLINE=$(sed 1q "$dotest/final-commit") + + if test -f "$dotest/final-commit" + then + FIRSTLINE=$(sed 1q "$dotest/final-commit") + else + FIRSTLINE="" + fi if test $action = skip then @@@ -735,8 -732,6 +741,8 @@@ resolved= git diff-index --quiet --cached HEAD -- && { echo "No changes - did you forget to use 'git add'?" + echo "If there is nothing left to stage, chances are that something else" + echo "already introduced the same changes; you might want to skip this patch." stop_here_user_resolve $this } unmerged=$(git ls-files -u) @@@ -751,7 -746,7 +757,7 @@@ ;; esac - if test $apply_status = 1 && test "$threeway" = t + if test $apply_status != 0 && test "$threeway" = t then if (fall_back_3way) then diff --combined t/t3400-rebase.sh index e5691bc5ed,c41bcc7d63..d98c7b5571 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@@ -10,8 -10,9 +10,9 @@@ among other things ' . ./test-lib.sh - GIT_AUTHOR_EMAIL=bogus_email_address - export GIT_AUTHOR_EMAIL + GIT_AUTHOR_NAME=author@name + GIT_AUTHOR_EMAIL=bogus@email@address + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL test_expect_success \ 'prepare repository with topic branches' \ @@@ -80,6 -81,10 +81,10 @@@ test_expect_success 'the rebase operation should not have destroyed author information' \ '! (git log | grep "Author:" | grep "<>")' + test_expect_success \ + 'the rebase operation should not have destroyed author information (2)' \ + "git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'" + test_expect_success 'HEAD was detached during rebase' ' test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1}) ' @@@ -126,20 -131,9 +131,20 @@@ test_expect_success 'Show verbose erro test_must_fail git rebase topic 2> output.err > output.out && grep "Untracked working tree file .B. would be overwritten" output.err ' +rm -f B + +test_expect_success 'dump usage when upstream arg is missing' ' + git checkout -b usage topic && + test_must_fail git rebase 2>error1 && + grep "[Uu]sage" error1 && + test_must_fail git rebase --abort 2>error2 && + grep "No rebase in progress" error2 && + test_must_fail git rebase --onto master 2>error3 && + grep "[Uu]sage" error3 && + ! grep "can.t shift" error3 +' test_expect_success 'rebase -q is quiet' ' - rm B && git checkout -b quiet topic && git rebase -q master > output.out 2>&1 && test ! -s output.out