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

[PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>}

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
May 21, 2013, 10:41 UTC
Message-ID
<1369132915-25657-3-git-send-email-artagnon@gmail.com>
In-Reply-To
<1369132915-25657-1-git-send-email-artagnon@gmail.com>

Currently, when we try to resolve @{<N>} or @{<date>} when the reflog for the current branch doesn't go back far enough, we get errors like:

  $ git show @{10000}
  fatal: Log for '' only has 7 entries.
  $ git show @{10000.days.ago}
  warning: Log for '' only goes back to Tue, 21 May 2013 14:14:45 +0530.
  ...

The empty string '' looks ugly and inconsistent with the output of <branch>@{<N>}. Replace it with the string 'current branch'.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sha1_name.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/sha1_name.c b/sha1_name.c
index 416a673..683b4bd 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -517,6 +517,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 		}
 		if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
 				&co_time, &co_tz, &co_cnt)) {
+			if (!len) {
+				str = "current branch";
+				len = strlen("current branch");
+			}
 			if (at_time)
 				warning("Log for '%.*s' only goes "
 					"back to %s.", len, str,
-- 
1.8.3.rc3.6.ga9126d5.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 19 in “Fix invalid revision error messages for 1.8.3”
  1. 0/2 Fix invalid revision error messages for 1.8.3Ramkumar Ramachandra, May 21, 2013
  2. 1/2 sha1_name: fix error message for @{u}Ramkumar Ramachandra, May 21, 2013
  3. Junio C HamanoMay 21, 2013
  4. Ramkumar RamachandraMay 21, 2013
  5. Junio C HamanoMay 21, 2013
  6. Ramkumar RamachandraMay 21, 2013
  7. Junio C HamanoMay 21, 2013
  8. Ramkumar RamachandraMay 21, 2013
  9. Junio C HamanoMay 21, 2013
  10. Ramkumar RamachandraMay 21, 2013
  11. Junio C HamanoMay 21, 2013
  12. 2/2 sha1_name: fix error message for @{<N>}, @{<date>}Ramkumar Ramachandra, May 21, 2013
  13. Junio C HamanoMay 21, 2013
  14. Kevin BraceyMay 21, 2013
  15. Ramkumar RamachandraMay 21, 2013
  16. Junio C HamanoMay 21, 2013
  17. Ramkumar RamachandraMay 21, 2013
  18. Junio C HamanoMay 21, 2013
  19. Ramkumar RamachandraMay 21, 2013

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.