Commit | Line | Data |
---|---|---|
fe847176 YD |
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 | ||
ff432158 CM |
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 && | |
f7a73141 | 17 | test $(stg branch) = "new" |
ff432158 | 18 | ' |
fe847176 | 19 | |
e152aab3 | 20 | test_expect_success \ |
e152aab3 | 21 | 'Create a spurious patches/ entry' ' |
ff432158 CM |
22 | stg branch master && |
23 | stg init && | |
e152aab3 | 24 | find .git -name foo | xargs rm -rf && |
262d31dc | 25 | mkdir -p .git/patches && touch .git/patches/foo |
fe847176 YD |
26 | ' |
27 | ||
5f594e90 | 28 | test_expect_success \ |
e152aab3 | 29 | 'Try to create an stgit branch with a spurious patches/ entry' ' |
5f594e90 | 30 | ! stg branch -c foo |
fe847176 YD |
31 | ' |
32 | ||
33 | test_expect_success \ | |
e152aab3 KH |
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 ) | |
37 | ' | |
38 | ||
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 | |
fe847176 YD |
43 | ' |
44 | ||
5f594e90 | 45 | test_expect_success \ |
e152aab3 | 46 | 'Try to create an stgit branch with an existing git branch by that name' ' |
5f594e90 | 47 | ! stg branch -c foo |
fe847176 YD |
48 | ' |
49 | ||
50 | test_expect_success \ | |
e152aab3 KH |
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 ) | |
fe847176 YD |
54 | ' |
55 | ||
e152aab3 KH |
56 | test_expect_success \ |
57 | 'Create an invalid refs/heads/ entry' ' | |
58 | find .git -name foo | xargs rm -rf && | |
91413512 CM |
59 | touch .git/refs/heads/foo && |
60 | ! stg branch -c foo | |
61 | ' | |
62 | ||
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 | |
72 | ' | |
73 | ||
b6586079 | 74 | test_expect_success \ |
91413512 | 75 | 'Create branch down the stack, behind the conflict caused by the generated file' ' |
b6586079 | 76 | ! stg branch --create bar master^ |
91413512 CM |
77 | ' |
78 | ||
79 | test_expect_success \ | |
80 | 'Check the branch was not created' ' | |
81 | test ! -r .git/refs/heads/bar && | |
82 | test ! -r a.c | |
e152aab3 | 83 | ' |
fe847176 | 84 | |
fe847176 | 85 | test_done |