reflog: improve error for when reflog is not found
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>
Karthik Nayak committed
Mar 14, 2025 at 09:40 UTC
52f2dfb08413d8be6ecbe86271dfe92e33cb67a2
2 files changed
+3
-3
builtin/reflog.c
+1
-1
@@ -383,7 +383,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
383
struct expire_reflog_policy_cb cb = { .cmd = cmd };
384
385
if (!repo_dwim_log(the_repository, argv[i], strlen(argv[i]), NULL, &ref)) {
386
- status |= error(_("%s points nowhere!"), argv[i]);
386
+ status |= error(_("reflog could not be found: '%s'"), argv[i]);
387
continue;
388
}
389
set_reflog_expiry_param(&cb.cmd, ref);
t/t1410-reflog.sh
+2
-2
@@ -315,9 +315,9 @@ test_expect_success 'git reflog expire unknown reference' '
315
test_config gc.reflogexpireunreachable never &&
316
317
test_must_fail git reflog expire main@{123} 2>stderr &&
318
- test_grep "points nowhere" stderr &&
318
+ test_grep "error: reflog could not be found: ${SQ}main@{123}${SQ}" stderr &&
319
test_must_fail git reflog expire does-not-exist 2>stderr &&
320
- test_grep "points nowhere" stderr
320
+ test_grep "error: reflog could not be found: ${SQ}does-not-exist${SQ}" stderr
321
'
322
323
test_expect_success 'checkout should not delete log for packed ref' '