Move identification of parent branch's remote def up into stack class.
[stgit] / t / t1000-branch-create.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Yann Dirson
4 #
5
6 test_description='Branch operations.
7
8 Exercises the "stg branch" commands.
9 '
10
11 . ./test-lib.sh
12
13 stg init
14
15 test_expect_failure \
16 'Try to create an stgit branch with a spurious refs/patches/ entry' \
17 'find .git -name foo | xargs rm -rf &&
18 touch .git/refs/patches/foo &&
19 stg branch -c foo
20 '
21
22 test_expect_success \
23 'Check no part of the branch was created' \
24 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/patches/foo" &&
25 ( grep foo .git/HEAD; test $? = 1 )
26 '
27
28 test_expect_failure \
29 'Try to create an stgit branch with a spurious patches/ entry' \
30 'find .git -name foo | xargs rm -rf &&
31 touch .git/patches/foo &&
32 stg branch -c foo
33 '
34
35 test_expect_success \
36 'Check no part of the branch was created' \
37 'test "`find .git -name foo | tee /dev/stderr`" = ".git/patches/foo" &&
38 ( grep foo .git/HEAD; test $? = 1 )
39 '
40
41 test_expect_failure \
42 'Try to create an stgit branch with a spurious refs/bases/ entry' \
43 'find .git -name foo | xargs rm -rf &&
44 touch .git/refs/bases/foo &&
45 stg branch -c foo
46 '
47
48 test_expect_success \
49 'Check no part of the branch was created' \
50 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/bases/foo" &&
51 ( grep foo .git/HEAD; test $? = 1 )
52 '
53
54
55 test_expect_failure \
56 'Try to create an stgit branch with an existing git branch by that name' \
57 'find .git -name foo | xargs rm -rf &&
58 cp .git/refs/heads/master .git/refs/heads/foo &&
59 stg branch -c foo
60 '
61
62 test_expect_success \
63 'Check no part of the branch was created' \
64 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" &&
65 ( grep foo .git/HEAD; test $? = 1 )
66 '
67
68
69 test_expect_failure \
70 'Try to create an stgit branch with an invalid refs/heads/ entry' \
71 'find .git -name foo | xargs rm -rf &&
72 touch .git/refs/heads/foo &&
73 stg branch -c foo
74 '
75
76 test_expect_success \
77 'Check no part of the branch was created' \
78 'test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" &&
79 ( grep foo .git/HEAD; test $? = 1 )
80 '
81
82 test_done