Skip to content

Commit

Permalink
t5520: test work tree fast-forward when fetch updates head
Browse files Browse the repository at this point in the history
Since b10ac50 (Fix pulling into the same branch., 2005-08-25), git-pull,
upon detecting that git-fetch updated the current head, will
fast-forward the working tree to the updated head commit.

Implement tests to ensure that the fast-forward occurs in such a case,
as well as to ensure that the user-friendly advice is printed upon
failure.

Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Paul Tan authored and Junio C Hamano committed May 29, 2015
1 parent 05438af commit 9f99226
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions t/t5520-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,27 @@ test_expect_success 'fail if the index has unresolved entries' '
test_cmp expected file
'

test_expect_success 'fast-forwards working tree if branch head is updated' '
git checkout -b third second^ &&
test_when_finished "git checkout -f copy && git branch -D third" &&
test "$(cat file)" = file &&
git pull . second:third 2>err &&
test_i18ngrep "fetch updated the current branch head" err &&
test "$(cat file)" = modified &&
test "$(git rev-parse third)" = "$(git rev-parse second)"
'

test_expect_success 'fast-forward fails with conflicting work tree' '
git checkout -b third second^ &&
test_when_finished "git checkout -f copy && git branch -D third" &&
test "$(cat file)" = file &&
echo conflict >file &&
test_must_fail git pull . second:third 2>err &&
test_i18ngrep "Cannot fast-forward your working tree" err &&
test "$(cat file)" = conflict &&
test "$(git rev-parse third)" = "$(git rev-parse second)"
'

test_expect_success '--rebase' '
git branch to-rebase &&
echo modified again > file &&
Expand Down

0 comments on commit 9f99226

Please sign in to comment.