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