X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/16d69115caef1a194384f0f0f668e6789b838909..f7a73141ca0db04818f958e68667f5b3f3019550:/t/t1000-branch-create.sh diff --git a/t/t1000-branch-create.sh b/t/t1000-branch-create.sh index 58209e7..fa51a24 100755 --- a/t/t1000-branch-create.sh +++ b/t/t1000-branch-create.sh @@ -10,59 +10,76 @@ Exercises the "stg branch" commands. . ./test-lib.sh -stg init +test_expect_success \ + 'Create a branch when the current one is not an StGIT stack' ' + git branch origin && + stg branch --create new origin && + test $(stg branch) = "new" +' -test_expect_failure \ - 'Try to create an stgit branch with a spurious refs/patches/ entry' \ - 'find .git -name foo | xargs rm -rf && - touch .git/refs/patches/foo && - stg branch -c foo +test_expect_success \ + 'Create a spurious patches/ entry' ' + stg branch master && + stg init && + find .git -name foo | xargs rm -rf && + mkdir -p .git/patches && touch .git/patches/foo ' test_expect_success \ - 'Check no part of the branch was created' \ - 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/patches/foo" && - ( grep foo .git/HEAD; test $? = 1 ) + 'Try to create an stgit branch with a spurious patches/ entry' ' + ! stg branch -c foo ' -test_expect_failure \ - 'Try to create an stgit branch with a spurious patches/ entry' \ - 'find .git -name foo | xargs rm -rf && - touch .git/patches/foo && - stg branch -c foo +test_expect_success \ + 'Check that no part of the branch was created' ' + test "`find .git -name foo | tee /dev/stderr`" = ".git/patches/foo" && + ( grep foo .git/HEAD; test $? = 1 ) ' test_expect_success \ - 'Check no part of the branch was created' \ - 'test "`find .git -name foo | tee /dev/stderr`" = ".git/patches/foo" && - ( grep foo .git/HEAD; test $? = 1 ) + 'Create a git branch' ' + find .git -name foo | xargs rm -rf && + cp .git/refs/heads/master .git/refs/heads/foo ' -test_expect_failure \ - 'Try to create an stgit branch with an existing git branch by that name' \ - 'find .git -name foo | xargs rm -rf && - cp .git/refs/heads/master .git/refs/heads/foo && - stg branch -c foo +test_expect_success \ + 'Try to create an stgit branch with an existing git branch by that name' ' + ! stg branch -c foo +' + +test_expect_success \ + 'Check that no part of the branch was created' ' + test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" && + ( grep foo .git/HEAD; test $? = 1 ) ' test_expect_success \ - 'Check no part of the branch was created' \ - 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" && - ( grep foo .git/HEAD; test $? = 1 ) + 'Create an invalid refs/heads/ entry' ' + find .git -name foo | xargs rm -rf && + touch .git/refs/heads/foo && + ! stg branch -c foo ' +test_expect_success \ + 'Setup two commits including removal of generated files' ' + git init && + touch a.c a.o && + git add a.c a.o && + git commit -m 1 && + git rm a.c a.o && + git commit -m 2 && + touch a.o +' test_expect_failure \ - 'Try to create an stgit branch with an invalid refs/heads/ entry' \ - 'find .git -name foo | xargs rm -rf && - touch .git/refs/heads/foo && - stg branch -c foo + 'Create branch down the stack, behind the conflict caused by the generated file' ' + stg branch --create bar master^ ' test_expect_success \ - 'Check no part of the branch was created' \ - 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" && - ( grep foo .git/HEAD; test $? = 1 ) + 'Check the branch was not created' ' + test ! -r .git/refs/heads/bar && + test ! -r a.c ' test_done