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

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:23

Ramkumar Ramachandra [off-list ref] writes:
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'.
Wouldn't that be '*the* current branch'?

More importantly, doesn't "real_ref" have the name of the branch?

Suppose the user said "git show @{10000}" instead of "git show
master@{10000}" while on 'master'.

It could be argued that it may look nicer to say "your current
branch does not have enough update history" instead of saying
"master does not..." (i.e. different input to ask for the same
thing, different output depending on the way the user asked).  It
also could be argued that they should produce the same diagnosis
that is more informative.

I am slightly leaning toward the latter.
quoted hunk
Signed-off-by: Ramkumar Ramachandra <redacted>
---
 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,

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

From: Kevin Bracey <hidden>
Date: 2016-06-15 22:57:23

On 21/05/2013 19:52, Junio C Hamano wrote:
Ramkumar Ramachandra [off-list ref] writes:
quoted
The empty string '' looks ugly and inconsistent with the output of
<branch>@{<N>}.  Replace it with the string 'current branch'.
Wouldn't that be '*the* current branch'?

More importantly, doesn't "real_ref" have the name of the branch?

Suppose the user said "git show @{10000}" instead of "git show
master@{10000}" while on 'master'.

It could be argued that it may look nicer to say "your current
branch does not have enough update history" instead of saying
"master does not..." (i.e. different input to ask for the same
thing, different output depending on the way the user asked).  It
also could be argued that they should produce the same diagnosis
that is more informative.

I am slightly leaning toward the latter.
That would also avoid the complaint I was about to make that putting 
'current branch' in scare quotes would be annoying.

Kevin

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

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:23

Junio C Hamano wrote:
More importantly, doesn't "real_ref" have the name of the branch?

Suppose the user said "git show @{10000}" instead of "git show
master@{10000}" while on 'master'.
My stupidity, sorry.
It could be argued that it may look nicer to say "your current
branch does not have enough update history" instead of saying
"master does not..." (i.e. different input to ask for the same
thing, different output depending on the way the user asked).  It
also could be argued that they should produce the same diagnosis
that is more informative.
Yeah, I wanted to discuss this: the problem is that even something as
low-level as rev-list will print this "pretty" error.  It's certainly
useful for porcelain.  How do we achieve this?  An extra
"is-porcelain" argument?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help