]>
Commit | Line | Data |
---|---|---|
166ec2e9 MZ |
1 | #!/bin/sh |
2 | ||
3 | test_description='git reset should work on unborn branch' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup' ' | |
7 | echo a >a && | |
8 | echo b >b | |
9 | ' | |
10 | ||
11 | test_expect_success 'reset' ' | |
12 | git add a b && | |
13 | git reset && | |
95728f74 | 14 | |
95728f74 | 15 | git ls-files >actual && |
d3c6751b | 16 | test_must_be_empty actual |
166ec2e9 MZ |
17 | ' |
18 | ||
19 | test_expect_success 'reset HEAD' ' | |
20 | rm .git/index && | |
21 | git add a b && | |
22 | test_must_fail git reset HEAD | |
23 | ' | |
24 | ||
25 | test_expect_success 'reset $file' ' | |
26 | rm .git/index && | |
27 | git add a b && | |
28 | git reset a && | |
95728f74 JN |
29 | |
30 | echo b >expect && | |
31 | git ls-files >actual && | |
32 | test_cmp expect actual | |
166ec2e9 MZ |
33 | ' |
34 | ||
c742f870 | 35 | test_expect_success PERL 'reset -p' ' |
166ec2e9 MZ |
36 | rm .git/index && |
37 | git add a && | |
95728f74 | 38 | echo y >yes && |
b3e9ce13 | 39 | git reset -p <yes >output && |
95728f74 | 40 | |
95728f74 | 41 | git ls-files >actual && |
d3c6751b | 42 | test_must_be_empty actual && |
b3e9ce13 | 43 | test_i18ngrep "Unstage" output |
166ec2e9 MZ |
44 | ' |
45 | ||
46 | test_expect_success 'reset --soft is a no-op' ' | |
47 | rm .git/index && | |
48 | git add a && | |
95728f74 JN |
49 | git reset --soft && |
50 | ||
51 | echo a >expect && | |
52 | git ls-files >actual && | |
53 | test_cmp expect actual | |
166ec2e9 MZ |
54 | ' |
55 | ||
56 | test_expect_success 'reset --hard' ' | |
57 | rm .git/index && | |
58 | git add a && | |
95728f74 | 59 | test_when_finished "echo a >a" && |
166ec2e9 | 60 | git reset --hard && |
95728f74 | 61 | |
95728f74 | 62 | git ls-files >actual && |
d3c6751b | 63 | test_must_be_empty actual && |
166ec2e9 MZ |
64 | test_path_is_missing a |
65 | ' | |
66 | ||
67 | test_done |