Test that git-branch -l works.
If the user supplies -l to git-branch when creating a new branch then the new branch's log should be created automatically and the branch creation should be logged in that log. Further if a branch is being deleted and it had a log then also verify that the log was deleted. Test git-checkout -b foo -l for creating a new branch foo with a log and checking out that branch. Fixed git-checkout -b foo -l as the branch variable name was incorrect in the script. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn Pearce committed
May 24, 2006 at 23:34 UTC
d7fb7a373a8ea4a8ecf6421be92226bab74f474e
2 files changed
+32
-3
git-checkout.sh
+2
-2
@@ -197,8 +197,8 @@ fi
197
if [ "$?" -eq 0 ]; then
198
if [ "$newbranch" ]; then
199
if [ "$newbranch_log" ]; then
200
- mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$branchname")
201
- touch "$GIT_DIR/logs/refs/heads/$branchname"
200
+ mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$newbranch")
201
+ touch "$GIT_DIR/logs/refs/heads/$newbranch"
202
fi
203
git-update-ref -m "checkout: Created from $new_name" "refs/heads/$newbranch" $new || exit
204
branch="$newbranch"
t/t3200-branch.sh
+30
-1
@@ -14,7 +14,8 @@ test_expect_success \
14
'prepare an trivial repository' \
15
'echo Hello > A &&
16
git-update-index --add A &&
17
- git-commit -m "Initial commit."'
17
+ git-commit -m "Initial commit." &&
18
+ HEAD=$(git-rev-parse --verify HEAD)'
19
20
test_expect_success \
21
'git branch --help should return success now.' \
@@ -32,4 +33,32 @@ test_expect_success \
33
'git branch a/b/c should create a branch' \
34
'git-branch a/b/c && test -f .git/refs/heads/a/b/c'
35
36
+cat >expect <<EOF
37
+0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from HEAD
38
+EOF
39
+test_expect_success \
40
+ 'git branch -l d/e/f should create a branch and a log' \
41
+ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
42
+ git-branch -l d/e/f &&
43
+ test -f .git/refs/heads/d/e/f &&
44
+ test -f .git/logs/refs/heads/d/e/f &&
45
+ diff expect .git/logs/refs/heads/d/e/f'
46
+
47
+test_expect_success \
48
+ 'git branch -d d/e/f should delete a branch and a log' \
49
+ 'git-branch -d d/e/f &&
50
+ test ! -f .git/refs/heads/d/e/f &&
51
+ test ! -f .git/logs/refs/heads/d/e/f'
52
+
53
+cat >expect <<EOF
54
+0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master^0
55
+EOF
56
+test_expect_success \
57
+ 'git checkout -b g/h/i -l should create a branch and a log' \
58
+ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
59
+ git-checkout -b g/h/i -l master &&
60
+ test -f .git/refs/heads/g/h/i &&
61
+ test -f .git/logs/refs/heads/g/h/i &&
62
+ diff expect .git/logs/refs/heads/g/h/i'
63
+
64
test_done