Commit | Line | Data |
---|---|---|
860d288d CM |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Catalin Marinas | |
4 | # | |
5 | ||
6 | test_description='Test the uncommit command. | |
7 | ||
8 | ' | |
9 | ||
10 | . ./test-lib.sh | |
11 | ||
12 | test_expect_success \ | |
13 | 'Initialize the StGIT repository' \ | |
14 | 'stg init | |
15 | ' | |
16 | ||
17 | test_expect_success \ | |
18 | 'Create the first patch' \ | |
19 | ' | |
20 | stg new foo -m "Foo Patch" && | |
21 | echo foo > test && | |
c7506039 | 22 | stg add test && |
860d288d CM |
23 | stg refresh |
24 | ' | |
25 | ||
26 | test_expect_success \ | |
27 | 'Create the second patch' \ | |
28 | ' | |
29 | stg new bar -m "Bar Patch" && | |
30 | echo bar > test && | |
c7506039 | 31 | stg add test && |
860d288d CM |
32 | stg refresh |
33 | ' | |
34 | ||
35 | test_expect_success \ | |
36 | 'Commit the patches' \ | |
37 | ' | |
980bde6a | 38 | stg commit --all |
860d288d CM |
39 | ' |
40 | ||
41 | test_expect_success \ | |
42 | 'Uncommit the patches using names' \ | |
43 | ' | |
44 | stg uncommit bar foo && | |
7c05b367 | 45 | [ "$(stg id foo)" = "$(stg id bar^)" ] && |
980bde6a | 46 | stg commit --all |
860d288d CM |
47 | ' |
48 | ||
49 | test_expect_success \ | |
50 | 'Uncommit the patches using prefix' \ | |
51 | ' | |
52 | stg uncommit --number=2 foobar && | |
7c05b367 | 53 | [ "$(stg id foobar1)" = "$(stg id foobar2^)" ] && |
980bde6a | 54 | stg commit --all |
860d288d CM |
55 | ' |
56 | ||
57 | test_expect_success \ | |
58 | 'Uncommit the patches using auto names' \ | |
59 | ' | |
60 | stg uncommit --number=2 && | |
7c05b367 | 61 | [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] && |
980bde6a | 62 | stg commit --all |
860d288d CM |
63 | ' |
64 | ||
65 | test_expect_success \ | |
66 | 'Uncommit the patches one by one' \ | |
67 | ' | |
68 | stg uncommit && | |
69 | stg uncommit && | |
7c05b367 | 70 | [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] && |
980bde6a | 71 | stg commit --all |
860d288d | 72 | ' |
d2f50b5d KH |
73 | |
74 | test_expect_success \ | |
75 | 'Uncommit the patches with --to' ' | |
76 | stg uncommit --to HEAD^ && | |
7c05b367 | 77 | [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] && |
980bde6a | 78 | stg commit --all |
d2f50b5d KH |
79 | ' |
80 | ||
4fe3436b | 81 | test_expect_success 'Uncommit a commit with not precisely one parent' ' |
145fa214 | 82 | command_error stg uncommit -n 5 && |
b9d9ba14 KH |
83 | [ "$(echo $(stg series))" = "" ] |
84 | ' | |
85 | ||
9beaff2e KH |
86 | # stg uncommit should work even when top != head, and should not touch |
87 | # the head. | |
bca31c2f | 88 | test_expect_success 'Uncommit when top != head' ' |
9beaff2e KH |
89 | stg new -m foo && |
90 | git reset --hard HEAD^ && | |
91 | h=$(git rev-parse HEAD) | |
92 | stg uncommit bar && | |
93 | test $(git rev-parse HEAD) = $h && | |
94 | test "$(echo $(stg series))" = "+ bar > foo" | |
95 | ' | |
96 | ||
860d288d | 97 | test_done |