Allow only certain gitk exit codes as valid
[stgit.git] / t / t1000-branch-create.sh
blobd6cf34a84b22286b76f3fc44b14b2a3360d7899e
1 #!/bin/sh
3 # Copyright (c) 2006 Yann Dirson
6 test_description='Branch operations.
8 Exercises the "stg branch" commands.
11 . ./test-lib.sh
13 test_expect_success \
14 'Create a branch when the current one is not an StGIT stack' '
15 git branch origin &&
16 stg branch --create new origin &&
17 test $(stg branch) = "new"
20 test_expect_success \
21 'Create a spurious patches/ entry' '
22 stg branch master &&
23 stg init &&
24 find .git -name foo | xargs rm -rf &&
25 mkdir -p .git/patches && touch .git/patches/foo
28 test_expect_success \
29 'Try to create an stgit branch with a spurious patches/ entry' '
30 ! stg branch -c foo
33 test_expect_success \
34 'Check that no part of the branch was created' '
35 test "`find .git -name foo | tee /dev/stderr`" = ".git/patches/foo" &&
36 ( grep foo .git/HEAD; test $? = 1 )
39 test_expect_success \
40 'Create a git branch' '
41 find .git -name foo | xargs rm -rf &&
42 cp .git/refs/heads/master .git/refs/heads/foo
45 test_expect_success \
46 'Try to create an stgit branch with an existing git branch by that name' '
47 ! stg branch -c foo
50 test_expect_success \
51 'Check that no part of the branch was created' '
52 test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" &&
53 ( grep foo .git/HEAD; test $? = 1 )
56 test_expect_success \
57 'Create an invalid refs/heads/ entry' '
58 find .git -name foo | xargs rm -rf &&
59 touch .git/refs/heads/foo &&
60 ! stg branch -c foo
63 test_expect_success \
64 'Setup two commits including removal of generated files' '
65 git init &&
66 touch a.c a.o &&
67 git add a.c a.o &&
68 git commit -m 1 &&
69 git rm a.c a.o &&
70 git commit -m 2 &&
71 touch a.o
74 test_expect_success \
75 'Create branch down the stack, behind the conflict caused by the generated file' '
76 ! stg branch --create bar master^
79 test_expect_success \
80 'Check the branch was not created' '
81 test ! -r .git/refs/heads/bar &&
82 test ! -r a.c
85 test_done