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 <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Paul Tan committed
May 29, 2015 at 19:44 UTC
9f992262fb8fdbac94f3a86f6bdf7182aab7feb6
1 file changed
+21
t/t5520-pull.sh
+21
@@ -183,6 +183,27 @@ test_expect_success 'fail if the index has unresolved entries' '
183
test_cmp expected file
184
'
185
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
+
207
test_expect_success '--rebase' '
208
git branch to-rebase &&
209
echo modified again > file &&