update-ref: pass reflog message to delete_ref()
authorKyle Meyer <kyle@kyleam.com>
Tue, 21 Feb 2017 01:10:33 +0000 (20:10 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Feb 2017 06:04:47 +0000 (22:04 -0800)
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 <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-ref.c
t/t1400-update-ref.sh

index 86d006d..0b2ecf4 100644 (file)
@@ -433,7 +433,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
                 * For purposes of backwards compatibility, we treat
                 * NULL_SHA1 as "don't care" here:
                 */
                 * For purposes of backwards compatibility, we treat
                 * NULL_SHA1 as "don't care" here:
                 */
-               return delete_ref(NULL, refname,
+               return delete_ref(msg, refname,
                                  (oldval && !is_null_sha1(oldsha1)) ? oldsha1 : NULL,
                                  flags);
        else
                                  (oldval && !is_null_sha1(oldsha1)) ? oldsha1 : NULL,
                                  flags);
        else
index b0ffc0b..6e112fb 100755 (executable)
@@ -85,6 +85,24 @@ test_expect_success "delete $m (by HEAD)" '
 '
 rm -f .git/$m
 
 '
 rm -f .git/$m
 
+test_expect_success "deleting current branch adds message to HEAD's log" '
+       git update-ref $m $A &&
+       git symbolic-ref HEAD $m &&
+       git update-ref -m delete-$m -d $m &&
+       ! test -f .git/$m &&
+       grep "delete-$m$" .git/logs/HEAD
+'
+rm -f .git/$m
+
+test_expect_success "deleting by HEAD adds message to HEAD's log" '
+       git update-ref $m $A &&
+       git symbolic-ref HEAD $m &&
+       git update-ref -m delete-by-head -d HEAD &&
+       ! test -f .git/$m &&
+       grep "delete-by-head$" .git/logs/HEAD
+'
+rm -f .git/$m
+
 test_expect_success 'update-ref does not create reflogs by default' '
        test_when_finished "git update-ref -d $outside" &&
        git update-ref $outside $A &&
 test_expect_success 'update-ref does not create reflogs by default' '
        test_when_finished "git update-ref -d $outside" &&
        git update-ref $outside $A &&