76
'
77
78
cat >expect <<EOF
79
-$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from main
79
+$HEAD refs/heads/d/e/f@{0}: branch: Created from main
80
EOF
81
test_expect_success 'git branch --create-reflog d/e/f should create a branch and a log' '
82
GIT_COMMITTER_DATE="2005-05-26 23:30" \
83
git -c core.logallrefupdates=false branch --create-reflog d/e/f &&
84
test_ref_exists refs/heads/d/e/f &&
85
- test_path_is_file .git/logs/refs/heads/d/e/f &&
86
- test_cmp expect .git/logs/refs/heads/d/e/f
85
+ git reflog show --no-abbrev-commit refs/heads/d/e/f >actual &&
86
+ test_cmp expect actual
87
'
88
89
test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
203
test $(git rev-parse --abbrev-ref HEAD) = bam
204
'
205
206
-test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '
207
- msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
208
- grep " $ZERO_OID.*$msg$" .git/logs/HEAD &&
209
- grep "^$ZERO_OID.*$msg$" .git/logs/HEAD
206
+test_expect_success 'git branch -M baz bam should add entries to HEAD reflog' '
207
+ git reflog show HEAD >actual &&
208
+ grep "HEAD@{0}: Branch: renamed refs/heads/baz to refs/heads/bam" actual
209
'
210
211
test_expect_success 'git branch -M should leave orphaned HEAD alone' '
227
test_expect_success 'resulting reflog can be shown by log -g' '
228
oid=$(git rev-parse HEAD) &&
229
cat >expect <<-EOF &&
231
- HEAD@{0} $oid $msg
230
+ HEAD@{0} $oid Branch: renamed refs/heads/baz to refs/heads/bam
231
HEAD@{2} $oid checkout: moving from foo to baz
232
EOF
233
git log -g --format="%gd %H %gs" -2 HEAD >actual &&
701
702
test_expect_success 'git branch -C c1 c2 should never touch HEAD' '
703
msg="Branch: copied refs/heads/c1 to refs/heads/c2" &&
705
- ! grep "$msg$" .git/logs/HEAD
704
+ git reflog HEAD >actual &&
705
+ ! grep "$msg$" actual
706
'
707
708
test_expect_success 'git branch -C main should work when main is checked out' '
1143
1144
# Keep this test last, as it changes the current branch
1145
cat >expect <<EOF
1146
-$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from main
1146
+$HEAD refs/heads/g/h/i@{0}: branch: Created from main
1147
EOF
1148
test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
1149
GIT_COMMITTER_DATE="2005-05-26 23:30" \
1150
git checkout -b g/h/i -l main &&
1151
test_ref_exists refs/heads/g/h/i &&
1152
- test_path_is_file .git/logs/refs/heads/g/h/i &&
1153
- test_cmp expect .git/logs/refs/heads/g/h/i
1152
+ git reflog show --no-abbrev-commit refs/heads/g/h/i >actual &&
1153
+ test_cmp expect actual
1154
'
1155
1156
test_expect_success 'checkout -b makes reflog by default' '