X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/b9d9ba14bf9fc47ab1ae9c41e6e37029b9f31002..de8efe1efc4a495eca0614aa9f6c1910d5838f99:/t/t1300-uncommit.sh diff --git a/t/t1300-uncommit.sh b/t/t1300-uncommit.sh index 0d952a7..5e9b8fb 100755 --- a/t/t1300-uncommit.sh +++ b/t/t1300-uncommit.sh @@ -19,7 +19,7 @@ test_expect_success \ ' stg new foo -m "Foo Patch" && echo foo > test && - git add test && + stg add test && stg refresh ' @@ -28,7 +28,7 @@ test_expect_success \ ' stg new bar -m "Bar Patch" && echo bar > test && - git add test && + stg add test && stg refresh ' @@ -42,7 +42,7 @@ test_expect_success \ 'Uncommit the patches using names' \ ' stg uncommit bar foo && - [ "$(stg id foo//top)" = "$(stg id bar//bottom)" ] && + [ "$(stg id foo)" = "$(stg id bar^)" ] && stg commit --all ' @@ -50,7 +50,7 @@ test_expect_success \ 'Uncommit the patches using prefix' \ ' stg uncommit --number=2 foobar && - [ "$(stg id foobar1//top)" = "$(stg id foobar2//bottom)" ] && + [ "$(stg id foobar1)" = "$(stg id foobar2^)" ] && stg commit --all ' @@ -58,7 +58,7 @@ test_expect_success \ 'Uncommit the patches using auto names' \ ' stg uncommit --number=2 && - [ "$(stg id foo-patch//top)" = "$(stg id bar-patch//bottom)" ] && + [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] && stg commit --all ' @@ -67,20 +67,31 @@ test_expect_success \ ' stg uncommit && stg uncommit && - [ "$(stg id foo-patch//top)" = "$(stg id bar-patch//bottom)" ] && + [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] && 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 id foo-patch)" = "$(stg id bar-patch^)" ] && stg commit --all ' -test_expect_failure 'Uncommit a commit with not precisely one parent' ' - stg uncommit -n 5 ; [ $? = 2 ] && +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