Skip to content

Commit 893dbf5

Browse files
kyleamgitster
authored andcommitted
rename_ref: replace empty message in HEAD's log
When the current branch is renamed, the deletion of the old ref is recorded in HEAD's log with an empty message. Now that delete_ref() accepts a reflog message, provide a more descriptive message by passing along the log message that is given to rename_ref(). The next step will be to extend HEAD's log to also include the second part of the rename, the creation of the new branch. Helped-by: Jeff King <[email protected]> Signed-off-by: Kyle Meyer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent de92266 commit 893dbf5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

refs/files-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ static int files_rename_ref(struct ref_store *ref_store,
26162616
return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s",
26172617
oldrefname, strerror(errno));
26182618

2619-
if (delete_ref(NULL, oldrefname, orig_sha1, REF_NODEREF)) {
2619+
if (delete_ref(logmsg, oldrefname, orig_sha1, REF_NODEREF)) {
26202620
error("unable to delete old %s", oldrefname);
26212621
goto rollback;
26222622
}

t/t3200-branch.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
139139
test $(git rev-parse --abbrev-ref HEAD) = bam
140140
'
141141

142+
test_expect_success 'git branch -M baz bam should add entry to .git/logs/HEAD' '
143+
msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
144+
grep " 0\{40\}.*$msg$" .git/logs/HEAD
145+
'
146+
142147
test_expect_success 'git branch -M baz bam should succeed when baz is checked out as linked working tree' '
143148
git checkout master &&
144149
git worktree add -b baz bazdir &&

0 commit comments

Comments
 (0)