]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reflog: improve error for when reflog is not found
authorKarthik Nayak <karthik.188@gmail.com>
Fri, 14 Mar 2025 08:40:34 +0000 (09:40 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Mar 2025 23:58:11 +0000 (16:58 -0700)
The 'git reflog expire' prints the error message '<ref> points nowhere!'
when used with a non-existent ref. This message is a bit confusing and
vague. Modify the message to be more clear and direct.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/reflog.c
t/t1410-reflog.sh

index 95f264989bbf1a955b3be528b84ce1fe525e8459..762719315e9a78a66902da311f3b72a8c3089c18 100644 (file)
@@ -383,7 +383,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
                struct expire_reflog_policy_cb cb = { .cmd = cmd };
 
                if (!repo_dwim_log(the_repository, argv[i], strlen(argv[i]), NULL, &ref)) {
-                       status |= error(_("%s points nowhere!"), argv[i]);
+                       status |= error(_("reflog could not be found: '%s'"), argv[i]);
                        continue;
                }
                set_reflog_expiry_param(&cb.cmd, ref);
index 388fdf9ae57dac4ed7d568e8043e090a445632cc..1f7249be76429571d0c43c28c4c8161ae0187e11 100755 (executable)
@@ -315,9 +315,9 @@ test_expect_success 'git reflog expire unknown reference' '
        test_config gc.reflogexpireunreachable never &&
 
        test_must_fail git reflog expire main@{123} 2>stderr &&
-       test_grep "points nowhere" stderr &&
+       test_grep "error: reflog could not be found: ${SQ}main@{123}${SQ}" stderr &&
        test_must_fail git reflog expire does-not-exist 2>stderr &&
-       test_grep "points nowhere" stderr
+       test_grep "error: reflog could not be found: ${SQ}does-not-exist${SQ}" stderr
 '
 
 test_expect_success 'checkout should not delete log for packed ref' '