1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 23:07:55 +01:00
git/t/t7106-reset-unborn-branch.sh
Jeff King b3e9ce1332 reset: pass real rev name to add--interactive
The add--interactive --patch mode adjusts the UI based on
whether we are pulling changes from HEAD or elsewhere (in
the former case it asks to unstage the reverse hunk, rather
than apply the forward hunk).

Commit 166ec2e taught reset to work on an unborn branch, but
in doing so, switched to always providing add--interactive
with the sha1 rather than the symbolic name. This meant we
always used the "apply" interface, even for "git reset -p
HEAD".

We can fix this by passing the symbolic name to
add--interactive.  Since it understands unborn branches
these days, we do not even have to cover this special case
ourselves; we can simply pass HEAD.

The tests in t7105 now check that the right interface is
used in each circumstance (and notice the regression from
166ec2e we are fixing). The test in t7106 checks that we
get this right for the unborn case, too (not a regression,
since it didn't work at all before, but a nice improvement).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-25 14:54:18 -07:00

70 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
test_description='git reset should work on unborn branch'
. ./test-lib.sh
test_expect_success 'setup' '
echo a >a &&
echo b >b
'
test_expect_success 'reset' '
git add a b &&
git reset &&
>expect &&
git ls-files >actual &&
test_cmp expect actual
'
test_expect_success 'reset HEAD' '
rm .git/index &&
git add a b &&
test_must_fail git reset HEAD
'
test_expect_success 'reset $file' '
rm .git/index &&
git add a b &&
git reset a &&
echo b >expect &&
git ls-files >actual &&
test_cmp expect actual
'
test_expect_success PERL 'reset -p' '
rm .git/index &&
git add a &&
echo y >yes &&
git reset -p <yes >output &&
>expect &&
git ls-files >actual &&
test_cmp expect actual &&
test_i18ngrep "Unstage" output
'
test_expect_success 'reset --soft is a no-op' '
rm .git/index &&
git add a &&
git reset --soft &&
echo a >expect &&
git ls-files >actual &&
test_cmp expect actual
'
test_expect_success 'reset --hard' '
rm .git/index &&
git add a &&
test_when_finished "echo a >a" &&
git reset --hard &&
>expect &&
git ls-files >actual &&
test_cmp expect actual &&
test_path_is_missing a
'
test_done