Skip to content

Commit fa14ee7

Browse files
pyokagangitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9570d67 commit fa14ee7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

t/t5520-pull.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,21 @@ test_expect_success 'pull --rebase works on branch yet to be born' '
412412
test_cmp expect actual
413413
'
414414

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+
415430
test_expect_success 'setup for detecting upstreamed changes' '
416431
mkdir src &&
417432
(cd src &&

0 commit comments

Comments
 (0)