]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'js/maint-am-rebase-invalid-author'
authorJunio C Hamano <gitster@pobox.com>
Sun, 27 Jun 2010 19:07:44 +0000 (12:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Jun 2010 19:07:44 +0000 (12:07 -0700)
* js/maint-am-rebase-invalid-author:
  am: use get_author_ident_from_commit instead of mailinfo when rebasing

1  2 
git-am.sh
t/t3400-rebase.sh

diff --combined git-am.sh
index ef2d51a2b80d77dc5fe28d76b5047a97dc4c0fae,abcb05b6baa8693fa6af021905b17a72d4f408e3..e7f008c7baae2ff484e16882e199b6b9d75195aa
+++ 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\"."
  
                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") &&
                        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"
                ;;
        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
        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
                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)
                ;;
        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 e5691bc5edc8d139c7238b59b0690834ba9e85f4,c41bcc7d635687f938312d4a6fbbf786738bca93..d98c7b5571245ccfebf19547186c3cf116a13cfe
@@@ -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