95728f74b1
Avoid command substitution and pipes to ensure that the exit status from each git command is tested (and in particular that any segfaults are caught). Maintain the test setup (no commits, one file named "a", another named "b") even after the last test, to make it easier to rearrange tests or add new tests after the last in the future. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
70 lines
1.1 KiB
Bash
Executable File
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 &&
|
|
|
|
>expect &&
|
|
git ls-files >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
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
|