]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/pull-rebase-ff' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 17 Jan 2017 23:11:04 +0000 (15:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Jan 2017 23:11:05 +0000 (15:11 -0800)
"git pull --rebase", when there is no new commits on our side since
we forked from the upstream, should be able to fast-forward without
invoking "git rebase", but it didn't.

* jc/pull-rebase-ff:
  pull: fast-forward "pull --rebase=true"

1  2 
builtin/pull.c
t/t5520-pull.sh

diff --cc builtin/pull.c
Simple merge
diff --cc t/t5520-pull.sh
index 551844584fc7b8ff71667dd61fcba62889ded69f,7887b6d97b762c3792b05257528ae38e6289bb99..17f4d0fe4e7244cb58eaedcf41bcaa9c7b157bb4
@@@ -255,38 -237,23 +255,55 @@@ test_expect_success '--rebase' 
        test new = "$(git show HEAD:file2)"
  '
  
+ test_expect_success '--rebase fast forward' '
+       git reset --hard before-rebase &&
+       git checkout -b ff &&
+       echo another modification >file &&
+       git commit -m third file &&
+       git checkout to-rebase &&
+       git pull --rebase . ff &&
+       test "$(git rev-parse HEAD)" = "$(git rev-parse ff)" &&
+       # The above only validates the result.  Did we actually bypass rebase?
+       git reflog -1 >reflog.actual &&
+       sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
+       echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected &&
+       test_cmp reflog.expected reflog.fuzzy
+ '
 +test_expect_success '--rebase with conflicts shows advice' '
 +      test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
 +      git checkout -b seq &&
 +      test_seq 5 >seq.txt &&
 +      git add seq.txt &&
 +      test_tick &&
 +      git commit -m "Add seq.txt" &&
 +      echo 6 >>seq.txt &&
 +      test_tick &&
 +      git commit -m "Append to seq.txt" seq.txt &&
 +      git checkout -b with-conflicts HEAD^ &&
 +      echo conflicting >>seq.txt &&
 +      test_tick &&
 +      git commit -m "Create conflict" seq.txt &&
 +      test_must_fail git pull --rebase . seq 2>err >out &&
 +      test_i18ngrep "When you have resolved this problem" out
 +'
 +
 +test_expect_success 'failed --rebase shows advice' '
 +      test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
 +      git checkout -b diverging &&
 +      test_commit attributes .gitattributes "* text=auto" attrs &&
 +      sha1="$(printf "1\\r\\n" | git hash-object -w --stdin)" &&
 +      git update-index --cacheinfo 0644 $sha1 file &&
 +      git commit -m v1-with-cr &&
 +      # force checkout because `git reset --hard` will not leave clean `file`
 +      git checkout -f -b fails-to-rebase HEAD^ &&
 +      test_commit v2-without-cr file "2" file2-lf &&
 +      test_must_fail git pull --rebase . diverging 2>err >out &&
 +      test_i18ngrep "When you have resolved this problem" out
 +'
 +
  test_expect_success '--rebase fails with multiple branches' '
        git reset --hard before-rebase &&
        test_must_fail git pull --rebase . copy master 2>err &&