]>
Commit | Line | Data |
---|---|---|
a3b427b9 AW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Amos Waterland | |
4 | # | |
5 | ||
6 | test_description='git branch --foo should not create bogus branch | |
7 | ||
8 | This test runs git branch --help and checks that the argument is properly | |
9 | handled. Specifically, that a bogus branch is not created. | |
10 | ' | |
11 | . ./test-lib.sh | |
12 | ||
13 | test_expect_success \ | |
14 | 'prepare an trivial repository' \ | |
15 | 'echo Hello > A && | |
bc6146d2 | 16 | git-update-index --add A && |
d7fb7a37 SP |
17 | git-commit -m "Initial commit." && |
18 | HEAD=$(git-rev-parse --verify HEAD)' | |
a3b427b9 | 19 | |
a3b427b9 AW |
20 | test_expect_failure \ |
21 | 'git branch --help should not have created a bogus branch' \ | |
5d9e8ee7 JH |
22 | 'git-branch --help </dev/null >/dev/null 2>/dev/null || : |
23 | test -f .git/refs/heads/--help' | |
a3b427b9 | 24 | |
08db81a9 AR |
25 | test_expect_success \ |
26 | 'git branch abc should create a branch' \ | |
27 | 'git-branch abc && test -f .git/refs/heads/abc' | |
28 | ||
29 | test_expect_success \ | |
30 | 'git branch a/b/c should create a branch' \ | |
31 | 'git-branch a/b/c && test -f .git/refs/heads/a/b/c' | |
32 | ||
d7fb7a37 | 33 | cat >expect <<EOF |
5d9e8ee7 | 34 | 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master |
d7fb7a37 SP |
35 | EOF |
36 | test_expect_success \ | |
37 | 'git branch -l d/e/f should create a branch and a log' \ | |
38 | 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ | |
39 | git-branch -l d/e/f && | |
40 | test -f .git/refs/heads/d/e/f && | |
41 | test -f .git/logs/refs/heads/d/e/f && | |
42 | diff expect .git/logs/refs/heads/d/e/f' | |
43 | ||
44 | test_expect_success \ | |
45 | 'git branch -d d/e/f should delete a branch and a log' \ | |
46 | 'git-branch -d d/e/f && | |
47 | test ! -f .git/refs/heads/d/e/f && | |
48 | test ! -f .git/logs/refs/heads/d/e/f' | |
49 | ||
50 | cat >expect <<EOF | |
51 | 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master^0 | |
52 | EOF | |
53 | test_expect_success \ | |
54 | 'git checkout -b g/h/i -l should create a branch and a log' \ | |
55 | 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ | |
56 | git-checkout -b g/h/i -l master && | |
57 | test -f .git/refs/heads/g/h/i && | |
58 | test -f .git/logs/refs/heads/g/h/i && | |
59 | diff expect .git/logs/refs/heads/g/h/i' | |
60 | ||
9c7b0b3f CC |
61 | test_expect_success \ |
62 | 'git branch j/k should work after branch j has been deleted' \ | |
63 | 'git-branch j && | |
64 | git-branch -d j && | |
65 | git-branch j/k' | |
66 | ||
67 | test_expect_success \ | |
68 | 'git branch l should work after branch l/m has been deleted' \ | |
69 | 'git-branch l/m && | |
70 | git-branch -d l/m && | |
71 | git-branch l' | |
72 | ||
c976d415 LH |
73 | test_expect_success \ |
74 | 'git branch -m m m/m should work' \ | |
75 | 'git-branch -l m && | |
76 | git-branch -m m m/m && | |
77 | test -f .git/logs/refs/heads/m/m' | |
78 | ||
79 | test_expect_success \ | |
80 | 'git branch -m n/n n should work' \ | |
81 | 'git-branch -l n/n && | |
82 | git-branch -m n/n n | |
83 | test -f .git/logs/refs/heads/n' | |
84 | ||
85 | test_expect_failure \ | |
86 | 'git branch -m o/o o should fail when o/p exists' \ | |
87 | 'git-branch o/o && | |
88 | git-branch o/p && | |
89 | git-branch -m o/o o' | |
90 | ||
91 | test_expect_failure \ | |
92 | 'git branch -m q r/q should fail when r exists' \ | |
93 | 'git-branch q && | |
94 | git-branch r && | |
95 | git-branch -m q r/q' | |
96 | ||
97 | test_expect_success \ | |
98 | 'git branch -m s/s s should work when s/t is deleted' \ | |
99 | 'git-branch -l s/s && | |
100 | test -f .git/logs/refs/heads/s/s && | |
101 | git-branch -l s/t && | |
102 | test -f .git/logs/refs/heads/s/t && | |
103 | git-branch -d s/t && | |
104 | git-branch -m s/s s && | |
105 | test -f .git/logs/refs/heads/s' | |
106 | ||
16c2bfbb LH |
107 | test_expect_failure \ |
108 | 'git-branch -m u v should fail when the reflog for u is a symlink' \ | |
109 | 'git-branch -l u && | |
110 | mv .git/logs/refs/heads/u real-u && | |
111 | ln -s real-u .git/logs/refs/heads/u && | |
112 | git-branch -m u v' | |
113 | ||
a3b427b9 | 114 | test_done |