summaryrefslogtreecommitdiff
path: root/t/t3200-branch.sh
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-02-21 01:10:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-21 06:04:47 (GMT)
commit39ee4c6c2fc80960094ae1454922c2d10c72f210 (patch)
treeb560d4925bc4e6ed3d49163b05352609e7615f7c /t/t3200-branch.sh
parent893dbf5ba16c47c7284209bc6c527195f368ee35 (diff)
downloadgit-39ee4c6c2fc80960094ae1454922c2d10c72f210.zip
git-39ee4c6c2fc80960094ae1454922c2d10c72f210.tar.gz
git-39ee4c6c2fc80960094ae1454922c2d10c72f210.tar.bz2
branch: record creation of renamed branch in HEAD's log
Renaming the current branch adds an event to the current branch's log and to HEAD's log. However, the logged entries differ. The entry in the branch's log represents the entire renaming operation (the old and new hash are identical), whereas the entry in HEAD's log represents the deletion only (the new sha1 is null). Extend replace_each_worktree_head_symref(), whose only caller is branch_rename(), to take a reflog message argument. This allows the creation of the new ref to be recorded in HEAD's log. As a result, the renaming event is represented by two entries (a deletion and a creation entry) in HEAD's log. It's a bit unfortunate that the branch's log and HEAD's log now represent the renaming event in different ways. Given that the renaming operation is not atomic, the two-entry form is a more accurate representation of the operation and is more useful for debugging purposes if a failure occurs between the deletion and creation events. It would make sense to move the branch's log to the two-entry form, but this would involve changes to how the rename is carried out and to how the update flags and reflogs are processed for deletions, so it may not be worth the effort. Based-on-patch-by: Jeff King <peff@peff.net> Signed-off-by: Kyle Meyer <kyle@kyleam.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3200-branch.sh')
-rwxr-xr-xt/t3200-branch.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 47bc151..e36ed3b 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -139,9 +139,10 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
test $(git rev-parse --abbrev-ref HEAD) = bam
'
-test_expect_success 'git branch -M baz bam should add entry to .git/logs/HEAD' '
+test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '
msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
- grep " 0\{40\}.*$msg$" .git/logs/HEAD
+ grep " 0\{40\}.*$msg$" .git/logs/HEAD &&
+ grep "^0\{40\}.*$msg$" .git/logs/HEAD
'
test_expect_success 'git branch -M baz bam should succeed when baz is checked out as linked working tree' '