3 # Copyright (c) 2006 Catalin Marinas
6 test_description
='Test the uncommit command.
13 'Initialize the StGIT repository' \
18 'Create the first patch' \
20 stg new foo -m "Foo Patch" &&
27 'Create the second patch' \
29 stg new bar -m "Bar Patch" &&
36 'Commit the patches' \
42 'Invalid --to and --number arguments' \
44 command_error stg uncommit --to HEAD^ --number 1 2>&1 |
45 grep -e "cannot give both --to and --number"
49 'Invalid --to with patch args' \
51 command_error stg uncommit --to HEAD^ p0 2>&1 |
52 grep -e "cannot specify patch name with --to"
58 command_error stg uncommit --number -1 2>&1 |
59 grep -e "invalid value passed to --number"
63 'Too many patch names with --number' \
65 command_error stg uncommit --number 2 p0 p1 2>&1 |
66 grep -e "when using --number, specify at most one patch name"
70 'Uncommit the patches using names' \
72 stg uncommit bar foo &&
73 [ "$(stg id foo)" = "$(stg id bar^)" ] &&
78 'Uncommit the patches using prefix' \
80 stg uncommit --number=2 foobar &&
81 [ "$(stg id foobar1)" = "$(stg id foobar2^)" ] &&
86 'Uncommit the patches using auto names' \
88 stg uncommit --number=2 &&
89 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
94 'Uncommit the patches one by one' \
98 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
102 test_expect_success \
103 'Uncommit the patches with --to' '
104 stg uncommit --to HEAD^ &&
105 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
109 test_expect_success \
112 stg uncommit --to HEAD^ --exclusive &&
113 [ "$(echo $(stg series --applied --noprefix))" = "bar-patch" ] &&
117 test_expect_success
'Attempt to reuse patch name' '
119 [ "$(echo $(stg series --applied --noprefix))" = "bar-patch" ] &&
120 command_error stg uncommit bar-patch 2>&1 |
121 grep -e "Patch name \"bar-patch\" already taken" &&
125 test_expect_success
'Uncommit a commit with not precisely one parent' '
126 command_error stg uncommit -n 5 &&
127 [ "$(echo $(stg series))" = "" ]
130 # stg uncommit should work even when top != head, and should not touch
132 test_expect_success
'Uncommit when top != head' '
134 git reset --hard HEAD^ &&
135 h=$(git rev-parse HEAD)
137 test "$(git rev-parse HEAD)" = "$h" &&
138 test "$(echo $(stg series))" = "+ bar > foo"