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 'Uncommit the patches using names' \
44 stg uncommit bar foo &&
45 [ "$(stg id foo)" = "$(stg id bar^)" ] &&
50 'Uncommit the patches using prefix' \
52 stg uncommit --number=2 foobar &&
53 [ "$(stg id foobar1)" = "$(stg id foobar2^)" ] &&
58 'Uncommit the patches using auto names' \
60 stg uncommit --number=2 &&
61 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
66 'Uncommit the patches one by one' \
70 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
75 'Uncommit the patches with --to' '
76 stg uncommit --to HEAD^ &&
77 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
81 test_expect_success
'Uncommit a commit with not precisely one parent' '
82 command_error stg uncommit -n 5 &&
83 [ "$(echo $(stg series))" = "" ]
86 # stg uncommit should work even when top != head, and should not touch
88 test_expect_success
'Uncommit when top != head' '
90 git reset --hard HEAD^ &&
91 h=$(git rev-parse HEAD)
93 test $(git rev-parse HEAD) = $h &&
94 test "$(echo $(stg series))" = "+ bar > foo"