chiark / gitweb /
Clean-up if the branch creation fails (bug #10015)
[stgit] / t / t1000-branch-create.sh
CommitLineData
fe847176
YD
1#!/bin/sh
2#
3# Copyright (c) 2006 Yann Dirson
4#
5
6test_description='Branch operations.
7
8Exercises the "stg branch" commands.
9'
10
11. ./test-lib.sh
12
13stg init
14
fe847176 15test_expect_success \
e152aab3
KH
16 'Create a spurious patches/ entry' '
17 find .git -name foo | xargs rm -rf &&
262d31dc 18 mkdir -p .git/patches && touch .git/patches/foo
fe847176
YD
19'
20
5f594e90 21test_expect_success \
e152aab3 22 'Try to create an stgit branch with a spurious patches/ entry' '
5f594e90 23 ! stg branch -c foo
fe847176
YD
24'
25
26test_expect_success \
e152aab3
KH
27 'Check that no part of the branch was created' '
28 test "`find .git -name foo | tee /dev/stderr`" = ".git/patches/foo" &&
29 ( grep foo .git/HEAD; test $? = 1 )
30'
31
32test_expect_success \
33 'Create a git branch' '
34 find .git -name foo | xargs rm -rf &&
35 cp .git/refs/heads/master .git/refs/heads/foo
fe847176
YD
36'
37
5f594e90 38test_expect_success \
e152aab3 39 'Try to create an stgit branch with an existing git branch by that name' '
5f594e90 40 ! stg branch -c foo
fe847176
YD
41'
42
43test_expect_success \
e152aab3
KH
44 'Check that no part of the branch was created' '
45 test "`find .git -name foo | tee /dev/stderr`" = ".git/refs/heads/foo" &&
46 ( grep foo .git/HEAD; test $? = 1 )
fe847176
YD
47'
48
e152aab3
KH
49test_expect_success \
50 'Create an invalid refs/heads/ entry' '
51 find .git -name foo | xargs rm -rf &&
91413512
CM
52 touch .git/refs/heads/foo &&
53 ! stg branch -c foo
54'
55
56test_expect_success \
57 'Setup two commits including removal of generated files' '
58 git init &&
59 touch a.c a.o &&
60 git add a.c a.o &&
61 git commit -m 1 &&
62 git rm a.c a.o &&
63 git commit -m 2 &&
64 touch a.o
65'
66
67test_expect_failure \
68 'Create branch down the stack, behind the conflict caused by the generated file' '
69 stg branch --create bar master^
70'
71
72test_expect_success \
73 'Check the branch was not created' '
74 test ! -r .git/refs/heads/bar &&
75 test ! -r a.c
e152aab3 76'
fe847176 77
fe847176 78test_done