]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rename_ref: replace empty message in HEAD's log
authorKyle Meyer <kyle@kyleam.com>
Tue, 21 Feb 2017 01:10:34 +0000 (20:10 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Feb 2017 06:04:47 +0000 (22:04 -0800)
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 <peff@peff.net>
Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c
t/t3200-branch.sh

index 299eb4d8afccde850a18e1755bc99e4e6cbf005d..f6e7c192c59f03acbd179055b219f70b7a4ca8a9 100644 (file)
@@ -2616,7 +2616,7 @@ static int files_rename_ref(struct ref_store *ref_store,
                return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s",
                        oldrefname, strerror(errno));
 
-       if (delete_ref(NULL, oldrefname, orig_sha1, REF_NODEREF)) {
+       if (delete_ref(logmsg, oldrefname, orig_sha1, REF_NODEREF)) {
                error("unable to delete old %s", oldrefname);
                goto rollback;
        }
index 8a833f354e331966f5f927ae94ac8686dd6d166f..47bc1512804ec24dcb9ea6a930900ca2202cdf38 100755 (executable)
@@ -139,6 +139,11 @@ 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' '
+       msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
+       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' '
        git checkout master &&
        git worktree add -b baz bazdir &&