Memorialize Python 3.7 support
[stgit.git] / t / t1000-branch-create.sh
blob220f00a33703f1084244f27f78ae29f58af5f148
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 mkdir -p .git/patches && touch .git/patches/foo1
27 test_expect_success \
28 'Try to create an stgit branch with a spurious patches/ entry' '
29 command_error stg branch -c foo1
32 test_expect_success \
33 'Check that no part of the branch was created' '
34 test "$(find .git -name foo1 | tee /dev/stderr)" = ".git/patches/foo1" &&
35 test $(git show-ref | grep foo1 | wc -l) -eq 0 &&
36 test "$(git symbolic-ref HEAD)" = "refs/heads/master"
39 test_expect_success \
40 'Create a git branch' '
41 git update-ref refs/heads/foo2 refs/heads/master
44 test_expect_success \
45 'Try to create an stgit branch with an existing git branch by that name' '
46 command_error stg branch -c foo2
49 test_expect_success \
50 'Check that no part of the branch was created' '
51 test $(find .git -name foo2 | tee /dev/stderr \
52 | grep -v ^\\.git/refs/heads/foo2$ \
53 | grep -v ^\\.git/logs/refs/heads/foo2$ | wc -l) -eq 0 &&
54 test $(git show-ref | grep foo2 | wc -l) -eq 1 &&
55 test "$(git symbolic-ref HEAD)" = "refs/heads/master"
58 test_expect_success \
59 'Create an invalid refs/heads/ entry' '
60 touch .git/refs/heads/foo3 &&
61 command_error stg branch -c foo3
64 test_expect_failure \
65 'Check that no part of the branch was created' '
66 test $(find .git -name foo3 | tee /dev/stderr \
67 | grep -v ^\\.git/refs/heads/foo3$ | wc -l) -eq 0 &&
68 test $(git show-ref | grep foo3 | wc -l) -eq 0 &&
69 test "$(git symbolic-ref HEAD)" = "refs/heads/master"
72 # Workaround for the test failure to make the rest of the subtests
73 # succeed. (HEAD was erroneously overwritten with the bad foo3 ref, so
74 # we need to reset it.)
75 git symbolic-ref HEAD refs/heads/master
77 test_expect_success \
78 'Setup two commits including removal of generated files' '
79 git init &&
80 touch file1 file2 &&
81 stg add file1 file2 &&
82 git commit -m 1 &&
83 stg rm file1 file2 &&
84 git commit -m 2 &&
85 touch file2
88 test_expect_success \
89 'Create branch down the stack, behind the conflict caused by the generated file' '
90 command_error stg branch --create foo4 master^
93 test_expect_success \
94 'Check the branch was not created' '
95 test ! -e file1 &&
96 test $(find .git -name foo4 | tee /dev/stderr | wc -l) -eq 0 &&
97 test $(git show-ref | grep foo4 | wc -l) -eq 0 &&
98 test "$(git symbolic-ref HEAD)" = "refs/heads/master"
101 test_done