'
stg new foo -m "Foo Patch" &&
echo foo > test &&
- stg add test &&
+ git add test &&
stg refresh
'
'
stg new bar -m "Bar Patch" &&
echo bar > test &&
- stg add test &&
+ git add test &&
stg refresh
'
test_expect_success \
'Commit the patches' \
'
- stg commit
+ stg commit --all
'
test_expect_success \
'Uncommit the patches using names' \
'
stg uncommit bar foo &&
- [ "$(stg id foo//top)" == "$(stg id bar//bottom)" ] &&
- stg commit
+ [ "$(stg id foo//top)" = "$(stg id bar//bottom)" ] &&
+ stg commit --all
'
test_expect_success \
'Uncommit the patches using prefix' \
'
stg uncommit --number=2 foobar &&
- [ "$(stg id foobar1//top)" == "$(stg id foobar2//bottom)" ] &&
- stg commit
+ [ "$(stg id foobar1//top)" = "$(stg id foobar2//bottom)" ] &&
+ stg commit --all
'
test_expect_success \
'Uncommit the patches using auto names' \
'
stg uncommit --number=2 &&
- [ "$(stg id foo-patch//top)" == "$(stg id bar-patch//bottom)" ] &&
- stg commit
+ [ "$(stg id foo-patch//top)" = "$(stg id bar-patch//bottom)" ] &&
+ stg commit --all
'
test_expect_success \
'
stg uncommit &&
stg uncommit &&
- [ "$(stg id foo-patch//top)" == "$(stg id bar-patch//bottom)" ] &&
- stg commit
+ [ "$(stg id foo-patch//top)" = "$(stg id bar-patch//bottom)" ] &&
+ stg commit --all
'
+
+test_expect_success \
+ 'Uncommit the patches with --to' '
+ stg uncommit --to HEAD^ &&
+ [ "$(stg id foo-patch//top)" = "$(stg id bar-patch//bottom)" ] &&
+ stg commit --all
+'
+
+test_expect_success 'Uncommit a commit with not precisely one parent' '
+ command_error stg uncommit -n 5 &&
+ [ "$(echo $(stg series))" = "" ]
+'
+
+# stg uncommit should work even when top != head, and should not touch
+# the head.
+test_expect_success 'Uncommit when top != head' '
+ stg new -m foo &&
+ git reset --hard HEAD^ &&
+ h=$(git rev-parse HEAD)
+ stg uncommit bar &&
+ test $(git rev-parse HEAD) = $h &&
+ test "$(echo $(stg series))" = "+ bar > foo"
+'
+
test_done