Skip to content

Commit de92266

Browse files
kyleamgitster
authored andcommitted
update-ref: pass reflog message to delete_ref()
Now that delete_ref() accepts a reflog message, pass the user-provided message to delete_ref() rather than silently dropping it. Signed-off-by: Kyle Meyer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 755b49a commit de92266

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

builtin/update-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
433433
* For purposes of backwards compatibility, we treat
434434
* NULL_SHA1 as "don't care" here:
435435
*/
436-
return delete_ref(NULL, refname,
436+
return delete_ref(msg, refname,
437437
(oldval && !is_null_sha1(oldsha1)) ? oldsha1 : NULL,
438438
flags);
439439
else

t/t1400-update-ref.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ test_expect_success "delete $m (by HEAD)" '
8585
'
8686
rm -f .git/$m
8787

88+
test_expect_success "deleting current branch adds message to HEAD's log" '
89+
git update-ref $m $A &&
90+
git symbolic-ref HEAD $m &&
91+
git update-ref -m delete-$m -d $m &&
92+
! test -f .git/$m &&
93+
grep "delete-$m$" .git/logs/HEAD
94+
'
95+
rm -f .git/$m
96+
97+
test_expect_success "deleting by HEAD adds message to HEAD's log" '
98+
git update-ref $m $A &&
99+
git symbolic-ref HEAD $m &&
100+
git update-ref -m delete-by-head -d HEAD &&
101+
! test -f .git/$m &&
102+
grep "delete-by-head$" .git/logs/HEAD
103+
'
104+
rm -f .git/$m
105+
88106
test_expect_success 'update-ref does not create reflogs by default' '
89107
test_when_finished "git update-ref -d $outside" &&
90108
git update-ref $outside $A &&

0 commit comments

Comments
 (0)