t5520: test --rebase failure on unborn branch with index

Commit 19a7fcb (allow pull --rebase on branch yet to be born, 2009-08-11) special cases git-pull on an unborn branch in a different code path such that git-pull --rebase is still valid even though there is no HEAD yet. This code path still ensures that there is no index in order not to lose any staged changes. Implement a test to ensure that this check is triggered. 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 fa14ee77ac7b0e4d16ede822015cad32f34b6c7f
1 file changed +15
t/t5520-pull.sh
+15
@@ -412,6 +412,21 @@ test_expect_success 'pull --rebase works on branch yet to be born' '
412 test_cmp expect actual
413 '
414
415 +test_expect_success 'pull --rebase fails on unborn branch with staged changes' '
416 + test_when_finished "rm -rf empty_repo2" &&
417 + git init empty_repo2 &&
418 + (
419 + cd empty_repo2 &&
420 + echo staged-file >staged-file &&
421 + git add staged-file &&
422 + test "$(git ls-files)" = staged-file &&
423 + test_must_fail git pull --rebase .. master 2>err &&
424 + test "$(git ls-files)" = staged-file &&
425 + test "$(git show :staged-file)" = staged-file &&
426 + test_i18ngrep "unborn branch with changes added to the index" err
427 + )
428 +'
429 +
430 test_expect_success 'setup for detecting upstreamed changes' '
431 mkdir src &&
432 (cd src &&