Skip to content

Commit 9f99226

Browse files
pyokagangitster
authored andcommitted
t5520: test work tree fast-forward when fetch updates head
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05438af commit 9f99226

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

t/t5520-pull.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,27 @@ test_expect_success 'fail if the index has unresolved entries' '
183183
test_cmp expected file
184184
'
185185

186+
test_expect_success 'fast-forwards working tree if branch head is updated' '
187+
git checkout -b third second^ &&
188+
test_when_finished "git checkout -f copy && git branch -D third" &&
189+
test "$(cat file)" = file &&
190+
git pull . second:third 2>err &&
191+
test_i18ngrep "fetch updated the current branch head" err &&
192+
test "$(cat file)" = modified &&
193+
test "$(git rev-parse third)" = "$(git rev-parse second)"
194+
'
195+
196+
test_expect_success 'fast-forward fails with conflicting work tree' '
197+
git checkout -b third second^ &&
198+
test_when_finished "git checkout -f copy && git branch -D third" &&
199+
test "$(cat file)" = file &&
200+
echo conflict >file &&
201+
test_must_fail git pull . second:third 2>err &&
202+
test_i18ngrep "Cannot fast-forward your working tree" err &&
203+
test "$(cat file)" = conflict &&
204+
test "$(git rev-parse third)" = "$(git rev-parse second)"
205+
'
206+
186207
test_expect_success '--rebase' '
187208
git branch to-rebase &&
188209
echo modified again > file &&

0 commit comments

Comments
 (0)