]>
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 JN |
14 | |
15 | >expect && | |
16 | git ls-files >actual && | |
17 | test_cmp expect actual | |
166ec2e9 MZ |
18 | ' |
19 | ||
20 | test_expect_success 'reset HEAD' ' | |
21 | rm .git/index && | |
22 | git add a b && | |
23 | test_must_fail git reset HEAD | |
24 | ' | |
25 | ||
26 | test_expect_success 'reset $file' ' | |
27 | rm .git/index && | |
28 | git add a b && | |
29 | git reset a && | |
95728f74 JN |
30 | |
31 | echo b >expect && | |
32 | git ls-files >actual && | |
33 | test_cmp expect actual | |
166ec2e9 MZ |
34 | ' |
35 | ||
c742f870 | 36 | test_expect_success PERL 'reset -p' ' |
166ec2e9 MZ |
37 | rm .git/index && |
38 | git add a && | |
95728f74 | 39 | echo y >yes && |
b3e9ce13 | 40 | git reset -p <yes >output && |
95728f74 JN |
41 | |
42 | >expect && | |
43 | git ls-files >actual && | |
b3e9ce13 JK |
44 | test_cmp expect actual && |
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 JN |
63 | |
64 | >expect && | |
65 | git ls-files >actual && | |
66 | test_cmp expect actual && | |
166ec2e9 MZ |
67 | test_path_is_missing a |
68 | ' | |
69 | ||
70 | test_done |