git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/2] reflog: improve error for when reflog is not found

From
Karthik Nayak <karthik.188@gmail.com>
Date
Mar 14, 2025, 08:40 UTC
Message-ID
<20250314-493-add-command-to-purge-reflog-entries-v3-1-c24e23a6146d@gmail.com>
In-Reply-To
<20250314-493-add-command-to-purge-reflog-entries-v3-0-c24e23a6146d@gmail.com>

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>
---
 builtin/reflog.c  | 2 +-
 t/t1410-reflog.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 95f264989b..762719315e 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -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);
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 388fdf9ae5..1f7249be76 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -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' '
-- 
2.48.1
Previous: Karthik NayakNext: Karthik Nayak
Message 23 of 30 in “EDITME: cover title for 493-add-command-to-purge-reflog-entries”
  1. 0/2 EDITME: cover title for 493-add-command-to-purge-reflog-entriesKarthik Nayak, Mar 7, 2025
  2. 1/2 reflog: drop usage of global variablesKarthik Nayak, Mar 7, 2025
  3. Junio C HamanoMar 7, 2025
  4. Karthik NayakMar 10, 2025
  5. Junio C HamanoMar 10, 2025
  6. Karthik NayakMar 13, 2025
  7. 2/2 reflog: implement subcommand to drop reflogsKarthik Nayak, Mar 7, 2025
  8. Patrick SteinhardtMar 7, 2025
  9. Karthik NayakMar 7, 2025
  10. Patrick SteinhardtMar 7, 2025
  11. Karthik NayakMar 7, 2025
  12. Karthik NayakMar 7, 2025
  13. Junio C HamanoMar 7, 2025
  14. Karthik NayakMar 10, 2025
  15. Kristoffer HaugsbakkMar 10, 2025
  16. Karthik NayakMar 10, 2025
  17. Junio C HamanoMar 10, 2025
  18. reflog: implement subcommand to drop reflogsKarthik Nayak, Mar 10, 2025
  19. Patrick SteinhardtMar 12, 2025
  20. Karthik NayakMar 13, 2025
  21. Patrick SteinhardtMar 13, 2025
  22. 0/2 reflog: implement subcommand to drop reflogsKarthik Nayak, Mar 14, 2025
  23. 1/2 reflog: improve error for when reflog is not foundKarthik Nayak, Mar 14, 2025
  24. 2/2 reflog: implement subcommand to drop reflogsKarthik Nayak, Mar 14, 2025
  25. Christian CouderMar 18, 2025
  26. Junio C HamanoMar 18, 2025
  27. Christian CouderMar 19, 2025
  28. Karthik NayakMar 19, 2025
  29. Toon ClaesMar 18, 2025
  30. Karthik NayakMar 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.