All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix invalid revision error messages for 1.8.3
@ 2013-05-21 10:41 Ramkumar Ramachandra
  2013-05-21 10:41 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 10:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Hi,

Seeing other patches on the list, I decided that I should do something
for 1.8.3 as well (as opposed to constantly writing new features).  So
here's my contribution.

The first error message has annoyed me endlessly, and I took this
opportunity to fix it.  Interested people can sprinkle in some advice
later.  The second one is a low-hanging "while we're there".

Thanks.

Ramkumar Ramachandra (2):
  sha1_name: fix error message for @{u}
  sha1_name: fix error message for @{<N>}, @{<date>}

 sha1_name.c                   | 17 +++++++++++------
 t/t1507-rev-parse-upstream.sh | 15 +++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)

-- 
1.8.3.rc3.6.ga9126d5.dirty

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 10:41 [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Ramkumar Ramachandra
@ 2013-05-21 10:41 ` Ramkumar Ramachandra
  2013-05-21 16:42   ` Junio C Hamano
  2013-05-21 10:41 ` [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>} Ramkumar Ramachandra
  2013-05-21 16:36 ` [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Junio C Hamano
  2 siblings, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 10:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Currently, when no (valid) upstream is configured for a branch, we get
an error like:

  $ git show @{u}
  error: No upstream configured for branch 'upstream-error'
  error: No upstream configured for branch 'upstream-error'
  fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

The "error: " line actually appears twice, and the rest of the error
message is useless.  In sha1_name.c:interpret_branch_name(), there is
really no point in processing further if @{u} couldn't be resolved, and
we might as well die() instead of returning an error().  After making
this change, you get:

  $ git show @{u}
  fatal: No upstream configured for branch 'upstream-error'

Also tweak a few tests in t1507 to expect this output.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sha1_name.c                   | 13 +++++++------
 t/t1507-rev-parse-upstream.sh | 15 +++++----------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 3820f28..416a673 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1033,14 +1033,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
 	 * points to something different than a branch.
 	 */
 	if (!upstream)
-		return error(_("HEAD does not point to a branch"));
+		die(_("HEAD does not point to a branch"));
 	if (!upstream->merge || !upstream->merge[0]->dst) {
 		if (!ref_exists(upstream->refname))
-			return error(_("No such branch: '%s'"), cp);
-		if (!upstream->merge)
-			return error(_("No upstream configured for branch '%s'"),
-				     upstream->name);
-		return error(
+			die(_("No such branch: '%s'"), cp);
+		if (!upstream->merge) {
+			die(_("No upstream configured for branch '%s'"),
+				upstream->name);
+		}
+		die(
 			_("Upstream branch '%s' not stored as a remote-tracking branch"),
 			upstream->merge[0]->src);
 	}
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index b27a720..2a19e79 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -129,8 +129,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
 
 test_expect_success 'branch@{u} error message when no upstream' '
 	cat >expect <<-EOF &&
-	error: No upstream configured for branch ${sq}non-tracking${sq}
-	fatal: Needed a single revision
+	fatal: No upstream configured for branch ${sq}non-tracking${sq}
 	EOF
 	error_message non-tracking@{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -138,8 +137,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
 
 test_expect_success '@{u} error message when no upstream' '
 	cat >expect <<-EOF &&
-	error: No upstream configured for branch ${sq}master${sq}
-	fatal: Needed a single revision
+	fatal: No upstream configured for branch ${sq}master${sq}
 	EOF
 	test_must_fail git rev-parse --verify @{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -147,8 +145,7 @@ test_expect_success '@{u} error message when no upstream' '
 
 test_expect_success 'branch@{u} error message with misspelt branch' '
 	cat >expect <<-EOF &&
-	error: No such branch: ${sq}no-such-branch${sq}
-	fatal: Needed a single revision
+	fatal: No such branch: ${sq}no-such-branch${sq}
 	EOF
 	error_message no-such-branch@{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -156,8 +153,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
 
 test_expect_success '@{u} error message when not on a branch' '
 	cat >expect <<-EOF &&
-	error: HEAD does not point to a branch
-	fatal: Needed a single revision
+	fatal: HEAD does not point to a branch
 	EOF
 	git checkout HEAD^0 &&
 	test_must_fail git rev-parse --verify @{u} 2>actual &&
@@ -166,8 +162,7 @@ test_expect_success '@{u} error message when not on a branch' '
 
 test_expect_success 'branch@{u} error message if upstream branch not fetched' '
 	cat >expect <<-EOF &&
-	error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
-	fatal: Needed a single revision
+	fatal: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
 	EOF
 	error_message bad-upstream@{u} 2>actual &&
 	test_i18ncmp expect actual
-- 
1.8.3.rc3.6.ga9126d5.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>}
  2013-05-21 10:41 [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Ramkumar Ramachandra
  2013-05-21 10:41 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
@ 2013-05-21 10:41 ` Ramkumar Ramachandra
  2013-05-21 16:52   ` Junio C Hamano
  2013-05-21 16:36 ` [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Junio C Hamano
  2 siblings, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 10:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/2] Fix invalid revision error messages for 1.8.3
  2013-05-21 10:41 [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Ramkumar Ramachandra
  2013-05-21 10:41 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
  2013-05-21 10:41 ` [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>} Ramkumar Ramachandra
@ 2013-05-21 16:36 ` Junio C Hamano
  2013-05-21 17:50   ` Ramkumar Ramachandra
  2 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 16:36 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Seeing other patches on the list, I decided that I should do something
> for 1.8.3 as well

Fixes to something that are broken the same way between 'master' and
older release versions are the same as enhancements (which you can
view as "fix to lack of feature").  They are not regression fixes
and not for 1.8.3 at this point in the cycle, deep into -rc.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 10:41 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
@ 2013-05-21 16:42   ` Junio C Hamano
  2013-05-21 17:56     ` Ramkumar Ramachandra
  0 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 16:42 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Currently, when no (valid) upstream is configured for a branch, we get
> an error like:
>
>   $ git show @{u}
>   error: No upstream configured for branch 'upstream-error'
>   error: No upstream configured for branch 'upstream-error'
>   fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
>   Use '--' to separate paths from revisions, like this:
>   'git <command> [<revision>...] -- [<file>...]'
>
> The "error: " line actually appears twice, and the rest of the error
> message is useless.  In sha1_name.c:interpret_branch_name(), there is
> really no point in processing further if @{u} couldn't be resolved, and
> we might as well die() instead of returning an error().  After making
> this change, you get:
>
>   $ git show @{u}
>   fatal: No upstream configured for branch 'upstream-error'
>
> Also tweak a few tests in t1507 to expect this output.

Does a failure in interpret-branch-name that issue these error
messages always followed by die() in the caller?  I know you looked
at the cases you noticed as an end-user (like the above "git show @{u}"
example), but if some codepaths did this:

	if (interpret-branch-name()) {
        	you do not seem to have upstream defined,
	        so I will helpfully do something else that
                you probably have meant.
	}

this patch will break that codepath you did not look.

I do not offhand know if there is such a codepath, so if you did a
code audit and know this patch is regression-free, please say that
in the log message.  "I ran all the tests and they passed" is not
good enough.

Other than that, the idea sounds OK.

>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  sha1_name.c                   | 13 +++++++------
>  t/t1507-rev-parse-upstream.sh | 15 +++++----------
>  2 files changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/sha1_name.c b/sha1_name.c
> index 3820f28..416a673 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -1033,14 +1033,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
>  	 * points to something different than a branch.
>  	 */
>  	if (!upstream)
> -		return error(_("HEAD does not point to a branch"));
> +		die(_("HEAD does not point to a branch"));
>  	if (!upstream->merge || !upstream->merge[0]->dst) {
>  		if (!ref_exists(upstream->refname))
> -			return error(_("No such branch: '%s'"), cp);
> -		if (!upstream->merge)
> -			return error(_("No upstream configured for branch '%s'"),
> -				     upstream->name);
> -		return error(
> +			die(_("No such branch: '%s'"), cp);
> +		if (!upstream->merge) {
> +			die(_("No upstream configured for branch '%s'"),
> +				upstream->name);
> +		}
> +		die(
>  			_("Upstream branch '%s' not stored as a remote-tracking branch"),
>  			upstream->merge[0]->src);
>  	}
> diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
> index b27a720..2a19e79 100755
> --- a/t/t1507-rev-parse-upstream.sh
> +++ b/t/t1507-rev-parse-upstream.sh
> @@ -129,8 +129,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
>  
>  test_expect_success 'branch@{u} error message when no upstream' '
>  	cat >expect <<-EOF &&
> -	error: No upstream configured for branch ${sq}non-tracking${sq}
> -	fatal: Needed a single revision
> +	fatal: No upstream configured for branch ${sq}non-tracking${sq}
>  	EOF
>  	error_message non-tracking@{u} 2>actual &&
>  	test_i18ncmp expect actual
> @@ -138,8 +137,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
>  
>  test_expect_success '@{u} error message when no upstream' '
>  	cat >expect <<-EOF &&
> -	error: No upstream configured for branch ${sq}master${sq}
> -	fatal: Needed a single revision
> +	fatal: No upstream configured for branch ${sq}master${sq}
>  	EOF
>  	test_must_fail git rev-parse --verify @{u} 2>actual &&
>  	test_i18ncmp expect actual
> @@ -147,8 +145,7 @@ test_expect_success '@{u} error message when no upstream' '
>  
>  test_expect_success 'branch@{u} error message with misspelt branch' '
>  	cat >expect <<-EOF &&
> -	error: No such branch: ${sq}no-such-branch${sq}
> -	fatal: Needed a single revision
> +	fatal: No such branch: ${sq}no-such-branch${sq}
>  	EOF
>  	error_message no-such-branch@{u} 2>actual &&
>  	test_i18ncmp expect actual
> @@ -156,8 +153,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
>  
>  test_expect_success '@{u} error message when not on a branch' '
>  	cat >expect <<-EOF &&
> -	error: HEAD does not point to a branch
> -	fatal: Needed a single revision
> +	fatal: HEAD does not point to a branch
>  	EOF
>  	git checkout HEAD^0 &&
>  	test_must_fail git rev-parse --verify @{u} 2>actual &&
> @@ -166,8 +162,7 @@ test_expect_success '@{u} error message when not on a branch' '
>  
>  test_expect_success 'branch@{u} error message if upstream branch not fetched' '
>  	cat >expect <<-EOF &&
> -	error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
> -	fatal: Needed a single revision
> +	fatal: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
>  	EOF
>  	error_message bad-upstream@{u} 2>actual &&
>  	test_i18ncmp expect actual

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>}
  2013-05-21 10:41 ` [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>} Ramkumar Ramachandra
@ 2013-05-21 16:52   ` Junio C Hamano
  2013-05-21 17:38     ` Kevin Bracey
  2013-05-21 18:09     ` Ramkumar Ramachandra
  0 siblings, 2 replies; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 16:52 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> 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.

> 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,

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>}
  2013-05-21 16:52   ` Junio C Hamano
@ 2013-05-21 17:38     ` Kevin Bracey
  2013-05-21 18:09     ` Ramkumar Ramachandra
  1 sibling, 0 replies; 23+ messages in thread
From: Kevin Bracey @ 2013-05-21 17:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ramkumar Ramachandra, Git List

On 21/05/2013 19:52, Junio C Hamano wrote:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
>> 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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/2] Fix invalid revision error messages for 1.8.3
  2013-05-21 16:36 ` [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Junio C Hamano
@ 2013-05-21 17:50   ` Ramkumar Ramachandra
  2013-05-21 17:57     ` Junio C Hamano
  0 siblings, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 17:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Junio C Hamano wrote:
> Fixes to something that are broken the same way between 'master' and
> older release versions are the same as enhancements (which you can
> view as "fix to lack of feature").  They are not regression fixes
> and not for 1.8.3 at this point in the cycle, deep into -rc.

If we view them as enhancements, well and good.  Let's polish them
until we're really happy with them: they're written with the "minimal,
but correct" philosophy, because the -rc3 window is too small for a
review.

Just to share opinion, they looked like "bugs" to me, because it's not
about "improving" the error messages; it's about correcting a defect.
The author could not have possibly intended two "error: " lines in the
first one, or an empty string in the second one.  At some point in the
past, the behavior must have been different (a "feature" must have
introduced these problems: like implicit HEAD for @{<N>}): the
"regression" was introduced in the version after that.  So, is it
because that version was too long ago that we don't consider it a
regression (do we backport fixes)?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 16:42   ` Junio C Hamano
@ 2013-05-21 17:56     ` Ramkumar Ramachandra
  2013-05-21 18:02       ` Junio C Hamano
  0 siblings, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 17:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Junio C Hamano wrote:
> Does a failure in interpret-branch-name that issue these error
> messages always followed by die() in the caller?  I know you looked
> at the cases you noticed as an end-user (like the above "git show @{u}"
> example), but if some codepaths did this:
>
>         if (interpret-branch-name()) {
>                 you do not seem to have upstream defined,
>                 so I will helpfully do something else that
>                 you probably have meant.
>         }
>
> this patch will break that codepath you did not look.

How can that ever happen in a non end-user case?  That failure
requires a string containing "@{u}" to be constructed and passed as an
argument.  Why would we ever programmatically construct "@{u}" to find
the upstream?

To put it another way: unless an end-user facing application finds an
"@{u}" while parsing argv and passes it on to interpret-branch-name,
isn't it impossible for an "@{u}" to end up in the argument?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/2] Fix invalid revision error messages for 1.8.3
  2013-05-21 17:50   ` Ramkumar Ramachandra
@ 2013-05-21 17:57     ` Junio C Hamano
  2013-05-21 18:16       ` Ramkumar Ramachandra
  0 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 17:57 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> So, is it
> because that version was too long ago that we don't consider it a
> regression (do we backport fixes)?

The "regression fixes" pre-release -rc period is for is to make sure
to avoid unwanted/unintended behaviour changes between releases.

People have _already_ seen and lived with these issues in released
versions.  Changing it may or may not be getting it back to the
state to that of an even older release, but at that point the
differences do not matter.  It is a "fix", too late for the kind of
regression fixes we focus during _this_ -rc period, which is about
regressions between v1.8.2 and 'master'.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 17:56     ` Ramkumar Ramachandra
@ 2013-05-21 18:02       ` Junio C Hamano
  2013-05-21 18:04         ` Ramkumar Ramachandra
  0 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 18:02 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Junio C Hamano wrote:
>> Does a failure in interpret-branch-name that issue these error
>> messages always followed by die() in the caller?  I know you looked
>> at the cases you noticed as an end-user (like the above "git show @{u}"
>> example), but if some codepaths did this:
>>
>>         if (interpret-branch-name()) {
>>                 you do not seem to have upstream defined,
>>                 so I will helpfully do something else that
>>                 you probably have meant.
>>         }
>>
>> this patch will break that codepath you did not look.
>
> How can that ever happen in a non end-user case?  That failure
> requires a string containing "@{u}" to be constructed and passed as an
> argument.  Why would we ever programmatically construct "@{u}" to find
> the upstream?
>
> To put it another way: unless an end-user facing application finds an
> "@{u}" while parsing argv and passes it on to interpret-branch-name,
> isn't it impossible for an "@{u}" to end up in the argument?

So did you or did you not audit the codepath?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 18:02       ` Junio C Hamano
@ 2013-05-21 18:04         ` Ramkumar Ramachandra
  2013-05-21 18:09           ` Junio C Hamano
  2013-05-21 19:19           ` Ramkumar Ramachandra
  0 siblings, 2 replies; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 18:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Junio C Hamano wrote:
> So did you or did you not audit the codepath?

No; I was explaining why I didn't in the first place.  Going through it now.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 18:04         ` Ramkumar Ramachandra
@ 2013-05-21 18:09           ` Junio C Hamano
  2013-05-21 19:19           ` Ramkumar Ramachandra
  1 sibling, 0 replies; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 18:09 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Junio C Hamano wrote:
>> So did you or did you not audit the codepath?
>
> No; I was explaining why I didn't in the first place.  Going through it now.

I did not mean "You must do so or we should discard the patch".  I
just wanted to make sure the log messages say how firmly the change
is backed.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>}
  2013-05-21 16:52   ` Junio C Hamano
  2013-05-21 17:38     ` Kevin Bracey
@ 2013-05-21 18:09     ` Ramkumar Ramachandra
  1 sibling, 0 replies; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 18:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

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?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/2] Fix invalid revision error messages for 1.8.3
  2013-05-21 17:57     ` Junio C Hamano
@ 2013-05-21 18:16       ` Ramkumar Ramachandra
  0 siblings, 0 replies; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 18:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Junio C Hamano wrote:
> People have _already_ seen and lived with these issues in released
> versions.  Changing it may or may not be getting it back to the
> state to that of an even older release, but at that point the
> differences do not matter.  It is a "fix", too late for the kind of
> regression fixes we focus during _this_ -rc period, which is about
> regressions between v1.8.2 and 'master'.

Makes sense.

On a related note, I really wonder why people run anything < master
git; it's so easy to compile and use from ~.  The idea isn't insane at
all: most people run a -p ruby from ~ using things like rbenv (yes, it
compiles from source).

(ofcourse servers have to run a release)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 18:04         ` Ramkumar Ramachandra
  2013-05-21 18:09           ` Junio C Hamano
@ 2013-05-21 19:19           ` Ramkumar Ramachandra
  2013-05-21 20:08             ` Junio C Hamano
  1 sibling, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 19:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Ramkumar Ramachandra wrote:
> Junio C Hamano wrote:
>> So did you or did you not audit the codepath?
>
> No; I was explaining why I didn't in the first place.  Going through it now.

So, this is what I have:

interpret_branch_name -> interpret_branch_name (recursion)
                      -> get_sha1_basic -> get_sha1 [context] (end-user data)
                      -> substitute_branch_name -> dwim (end-user data)
		      -> strbuf_branchname (callers pass a branch name; no @{u})
		      -> revision.c:add_pending_object [with_mode] (end-user data)

[die_]verify_filename -> builtin/rev-parse.c (end-user)
		      -> builtin/reset.c (end-user)
		      -> builtin/grep.c:cmd_grep (end-user)
		      -> revision.c:setup_revisions (end-user data)

We used to die in die_verify_filename() earlier, but we die in
interpret_branch_name() after the patch.  Do we have to dig deeper?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 19:19           ` Ramkumar Ramachandra
@ 2013-05-21 20:08             ` Junio C Hamano
  2013-05-21 20:14               ` Ramkumar Ramachandra
  0 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 20:08 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Ramkumar Ramachandra wrote:
>> Junio C Hamano wrote:
>>> So did you or did you not audit the codepath?
>>
>> No; I was explaining why I didn't in the first place.  Going through it now.
>
> So, this is what I have:
>
> interpret_branch_name -> interpret_branch_name (recursion)
>                       -> get_sha1_basic -> get_sha1 [context] (end-user data)
>                       -> substitute_branch_name -> dwim (end-user data)
> 		      -> strbuf_branchname (callers pass a branch name; no @{u})
> 		      -> revision.c:add_pending_object [with_mode] (end-user data)
>
> [die_]verify_filename -> builtin/rev-parse.c (end-user)
> 		      -> builtin/reset.c (end-user)
> 		      -> builtin/grep.c:cmd_grep (end-user)
> 		      -> revision.c:setup_revisions (end-user data)

It seems that you are digging in the wrong direction?  I was worried
about the callers of interpret_branch_name().

But whatever.

I looked at the callers myself while waiting for the test suite to
pass for five integration branches and I think the patch is safe.
There were some silent error returns from the function but your
patch did not touch them (which is good).

> We used to die in die_verify_filename() earlier, but we die in
> interpret_branch_name() after the patch.

I think that is a desired outcome.  Thanks.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 20:08             ` Junio C Hamano
@ 2013-05-21 20:14               ` Ramkumar Ramachandra
  2013-05-21 20:33                 ` Junio C Hamano
  0 siblings, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-21 20:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Junio C Hamano wrote:
>> interpret_branch_name -> interpret_branch_name (recursion)
>>                       -> get_sha1_basic -> get_sha1 [context] (end-user data)
>>                       -> substitute_branch_name -> dwim (end-user data)
>>                     -> strbuf_branchname (callers pass a branch name; no @{u})
>>                     -> revision.c:add_pending_object [with_mode] (end-user data)
>>
>> [die_]verify_filename -> builtin/rev-parse.c (end-user)
>>                     -> builtin/reset.c (end-user)
>>                     -> builtin/grep.c:cmd_grep (end-user)
>>                     -> revision.c:setup_revisions (end-user data)
>
> It seems that you are digging in the wrong direction?  I was worried
> about the callers of interpret_branch_name().

Um, aren't interpret_branch_name, get_sha1_basic,
substitute_branch_name, strbuf_branchname, and add_pending_object the
five callers of interpret_branch_name?  I've tried to show how they
are called with either end-user data or programmatic data without a
"@{u}".  What am I missing?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-21 20:14               ` Ramkumar Ramachandra
@ 2013-05-21 20:33                 ` Junio C Hamano
  0 siblings, 0 replies; 23+ messages in thread
From: Junio C Hamano @ 2013-05-21 20:33 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> "@{u}".  What am I missing?

You draw the arrow the other way around, that is what made the text
confusing.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-24  7:42 [PATCH v3 0/2] Replacement for rr/die-on-missing-upstream Ramkumar Ramachandra
@ 2013-05-24  7:42 ` Ramkumar Ramachandra
  0 siblings, 0 replies; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-24  7:42 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Currently, when no (valid) upstream is configured for a branch, you get
an error like:

  $ git show @{u}
  error: No upstream configured for branch 'upstream-error'
  error: No upstream configured for branch 'upstream-error'
  fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

The "error: " line actually appears twice, and the rest of the error
message is useless.  In sha1_name.c:interpret_branch_name(), there is
really no point in processing further if @{u} couldn't be resolved, and
we might as well die() instead of returning an error().  After making
this change, you get:

  $ git show @{u}
  fatal: No upstream configured for branch 'upstream-error'

Also tweak a few tests in t1507 to expect this output.

To justify that this change is safe, consider that all callers of
interpret_branch_name() have to fall in two categories:

1. Direct end-user facing applications like [rev-parse, show] calling in
   with end-user data (in which case the data can contain "@{u}").
   Failing immediately is the right thing to do: the only difference is
   that the die() happens in interpret_branch_name() instead of
   die_verify_filename(), and this is desirable.

2. Callers calling in with programmatic data, and expecting the function
   to return and not die().  In this case, why would anyone ever
   construct a string containing "@{u}" programmatically in the first
   place?  A grep reveals that no part of the code hard-codes either
   "@{u}" or "@{upstream}".  So, these callers will never hit the
   codepath touched by the patch.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sha1_name.c                   | 11 +++++------
 t/t1507-rev-parse-upstream.sh | 15 +++++----------
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 3820f28..61f5a34 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1033,15 +1033,14 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
 	 * points to something different than a branch.
 	 */
 	if (!upstream)
-		return error(_("HEAD does not point to a branch"));
+		die(_("HEAD does not point to a branch"));
 	if (!upstream->merge || !upstream->merge[0]->dst) {
 		if (!ref_exists(upstream->refname))
-			return error(_("No such branch: '%s'"), cp);
+			die(_("No such branch: '%s'"), cp);
 		if (!upstream->merge)
-			return error(_("No upstream configured for branch '%s'"),
-				     upstream->name);
-		return error(
-			_("Upstream branch '%s' not stored as a remote-tracking branch"),
+			die(_("No upstream configured for branch '%s'"),
+				upstream->name);
+		die(_("Upstream branch '%s' not stored as a remote-tracking branch"),
 			upstream->merge[0]->src);
 	}
 	free(cp);
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index b27a720..2a19e79 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -129,8 +129,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
 
 test_expect_success 'branch@{u} error message when no upstream' '
 	cat >expect <<-EOF &&
-	error: No upstream configured for branch ${sq}non-tracking${sq}
-	fatal: Needed a single revision
+	fatal: No upstream configured for branch ${sq}non-tracking${sq}
 	EOF
 	error_message non-tracking@{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -138,8 +137,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
 
 test_expect_success '@{u} error message when no upstream' '
 	cat >expect <<-EOF &&
-	error: No upstream configured for branch ${sq}master${sq}
-	fatal: Needed a single revision
+	fatal: No upstream configured for branch ${sq}master${sq}
 	EOF
 	test_must_fail git rev-parse --verify @{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -147,8 +145,7 @@ test_expect_success '@{u} error message when no upstream' '
 
 test_expect_success 'branch@{u} error message with misspelt branch' '
 	cat >expect <<-EOF &&
-	error: No such branch: ${sq}no-such-branch${sq}
-	fatal: Needed a single revision
+	fatal: No such branch: ${sq}no-such-branch${sq}
 	EOF
 	error_message no-such-branch@{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -156,8 +153,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
 
 test_expect_success '@{u} error message when not on a branch' '
 	cat >expect <<-EOF &&
-	error: HEAD does not point to a branch
-	fatal: Needed a single revision
+	fatal: HEAD does not point to a branch
 	EOF
 	git checkout HEAD^0 &&
 	test_must_fail git rev-parse --verify @{u} 2>actual &&
@@ -166,8 +162,7 @@ test_expect_success '@{u} error message when not on a branch' '
 
 test_expect_success 'branch@{u} error message if upstream branch not fetched' '
 	cat >expect <<-EOF &&
-	error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
-	fatal: Needed a single revision
+	fatal: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
 	EOF
 	error_message bad-upstream@{u} 2>actual &&
 	test_i18ncmp expect actual
-- 
1.8.3.rc3.17.gd95ec6c.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-22 17:35   ` Junio C Hamano
@ 2013-05-23 11:03     ` Ramkumar Ramachandra
  0 siblings, 0 replies; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-23 11:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Junio C Hamano wrote:
> If you have to ask why, and cannot answer the question yourself,
> then you would not know if such a caller exists.  After a code
> audit, I know there is no such caller that appends @{u} but if you
> were writing a quick-and-dirty caller, I would not be surprised if
> you find it more convenient to form a textual extended SHA-1
> expression and have get_sha1() do its work, instead of asking the
> same question programmatically.

I'll mention that a simple grep for "@{u}" and "@{upstream}" found nothing.

> In this case, I think you already checked there is no such problem,
> and it is a more straight-forward justification to say that you did
> a code-audit and made sure that all the callers that used to hit one
> of these errors() want to die().

It's not about callers eventually wanting to die(); it's about whether
callers want to die() without doing anything useful after getting this
-1.  And that is impossible for me to say with confidence, unless I do
a _very_ extensive code review (which I didn't do).

> Also such a caller, if existed, would either
>
>     (1) want to die itself, in which case these error() messages are
>         superfluous; or
>
>     (2) want to continue (possibly dying with its own message), in
>         which case these error() messages are unwanted.
>
> Because you are changing only the existing call sites of error()
> into die(), and not changing silent -1 returns to die(), this change
> is safe for both kinds of such callers, I think.

Take the example of git branch (-vv) output: let's imagine a universe
in which it determines upstream by calling in with a hard-coded "@{u}"
string.  Should the entire program die() and stop printing the rest of
the branches?  Ofcourse not.  Is your argument that no caller should
do this in the first place, because of spurious error() messages
polluting the output (of git branch)?  How is this argument stronger
than my grep for "@{u}"?

>> +             die(
>>                       _("Upstream branch '%s' not stored as a remote-tracking branch"),
>>                       upstream->merge[0]->src);
>
> OK, but I would fix the indentation while at it if I were doing this change.

But my Emacs reports that the indentation is correct.  Did you mean:

diff --git a/sha1_name.c b/sha1_name.c
index b7e008a..b00ea0f 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1051,8 +1051,7 @@ int interpret_branch_name(const char *name,
struct strbuf *buf)
 			die(_("No upstream configured for branch '%s'"),
 				upstream->name);
 		}
-		die(
-			_("Upstream branch '%s' not stored as a remote-tracking branch"),
+		die(_("Upstream branch '%s' not stored as a remote-tracking branch"),
 			upstream->merge[0]->src);
 	}
 	free(cp);


Yeah, I'll do this.

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-22 10:39 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
@ 2013-05-22 17:35   ` Junio C Hamano
  2013-05-23 11:03     ` Ramkumar Ramachandra
  0 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2013-05-22 17:35 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> 2. Callers calling in with programmatic data, and expecting the function
>    to return and not die().  In this case, why would anyone ever
>    construct a string containing "@{u}" programmatically in the first
>    place?

If you have to ask why, and cannot answer the question yourself,
then you would not know if such a caller exists.  After a code
audit, I know there is no such caller that appends @{u} but if you
were writing a quick-and-dirty caller, I would not be surprised if
you find it more convenient to form a textual extended SHA-1
expression and have get_sha1() do its work, instead of asking the
same question programmatically.

In this case, I think you already checked there is no such problem,
and it is a more straight-forward justification to say that you did
a code-audit and made sure that all the callers that used to hit one
of these errors() want to die().

Also such a caller, if existed, would either

    (1) want to die itself, in which case these error() messages are
        superfluous; or

    (2) want to continue (possibly dying with its own message), in
        which case these error() messages are unwanted.

Because you are changing only the existing call sites of error()
into die(), and not changing silent -1 returns to die(), this change
is safe for both kinds of such callers, I think.

> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  sha1_name.c                   | 13 +++++++------
>  t/t1507-rev-parse-upstream.sh | 15 +++++----------
>  2 files changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/sha1_name.c b/sha1_name.c
> index 3820f28..416a673 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -1033,14 +1033,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
>  	 * points to something different than a branch.
>  	 */
>  	if (!upstream)
> -		return error(_("HEAD does not point to a branch"));
> +		die(_("HEAD does not point to a branch"));

OK.

>  	if (!upstream->merge || !upstream->merge[0]->dst) {
>  		if (!ref_exists(upstream->refname))
> +			die(_("No such branch: '%s'"), cp);

OK.

> +		if (!upstream->merge) {
> +			die(_("No upstream configured for branch '%s'"),
> +				upstream->name);
> +		}

OK, but I would not add extra {} if I were doing this change.

> +		die(
>  			_("Upstream branch '%s' not stored as a remote-tracking branch"),
>  			upstream->merge[0]->src);

OK, but I would fix the indentation while at it if I were doing this change.

> diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
> index b27a720..2a19e79 100755
> --- a/t/t1507-rev-parse-upstream.sh
> +++ b/t/t1507-rev-parse-upstream.sh
> @@ -129,8 +129,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
>  
>  test_expect_success 'branch@{u} error message when no upstream' '
>  	cat >expect <<-EOF &&
> -	error: No upstream configured for branch ${sq}non-tracking${sq}
> -	fatal: Needed a single revision
> +	fatal: No upstream configured for branch ${sq}non-tracking${sq}

Much nicer.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/2] sha1_name: fix error message for @{u}
  2013-05-22 10:39 [PATCH v2 0/2] Fix invalid revision error messages Ramkumar Ramachandra
@ 2013-05-22 10:39 ` Ramkumar Ramachandra
  2013-05-22 17:35   ` Junio C Hamano
  0 siblings, 1 reply; 23+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-22 10:39 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Currently, when no (valid) upstream is configured for a branch, you get
an error like:

  $ git show @{u}
  error: No upstream configured for branch 'upstream-error'
  error: No upstream configured for branch 'upstream-error'
  fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

The "error: " line actually appears twice, and the rest of the error
message is useless.  In sha1_name.c:interpret_branch_name(), there is
really no point in processing further if @{u} couldn't be resolved, and
we might as well die() instead of returning an error().  After making
this change, you get:

  $ git show @{u}
  fatal: No upstream configured for branch 'upstream-error'

Also tweak a few tests in t1507 to expect this output.

To justify that this change is safe, consider that all callers of
interpret_branch_name() have to fall in two categories:

1. Direct end-user facing applications like [rev-parse, show] calling in
   with end-user data (in which case the data can contain "@{u}").
   Failing immediately is the right thing to do: the only difference is
   that the die() happens in interpret_branch_name() instead of
   die_verify_filename(), and this is desirable.

2. Callers calling in with programmatic data, and expecting the function
   to return and not die().  In this case, why would anyone ever
   construct a string containing "@{u}" programmatically in the first
   place?  So, these callers can never hit the codepath touched by this
   patch, and the change does not affect them.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sha1_name.c                   | 13 +++++++------
 t/t1507-rev-parse-upstream.sh | 15 +++++----------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 3820f28..416a673 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1033,14 +1033,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
 	 * points to something different than a branch.
 	 */
 	if (!upstream)
-		return error(_("HEAD does not point to a branch"));
+		die(_("HEAD does not point to a branch"));
 	if (!upstream->merge || !upstream->merge[0]->dst) {
 		if (!ref_exists(upstream->refname))
-			return error(_("No such branch: '%s'"), cp);
-		if (!upstream->merge)
-			return error(_("No upstream configured for branch '%s'"),
-				     upstream->name);
-		return error(
+			die(_("No such branch: '%s'"), cp);
+		if (!upstream->merge) {
+			die(_("No upstream configured for branch '%s'"),
+				upstream->name);
+		}
+		die(
 			_("Upstream branch '%s' not stored as a remote-tracking branch"),
 			upstream->merge[0]->src);
 	}
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index b27a720..2a19e79 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -129,8 +129,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
 
 test_expect_success 'branch@{u} error message when no upstream' '
 	cat >expect <<-EOF &&
-	error: No upstream configured for branch ${sq}non-tracking${sq}
-	fatal: Needed a single revision
+	fatal: No upstream configured for branch ${sq}non-tracking${sq}
 	EOF
 	error_message non-tracking@{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -138,8 +137,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
 
 test_expect_success '@{u} error message when no upstream' '
 	cat >expect <<-EOF &&
-	error: No upstream configured for branch ${sq}master${sq}
-	fatal: Needed a single revision
+	fatal: No upstream configured for branch ${sq}master${sq}
 	EOF
 	test_must_fail git rev-parse --verify @{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -147,8 +145,7 @@ test_expect_success '@{u} error message when no upstream' '
 
 test_expect_success 'branch@{u} error message with misspelt branch' '
 	cat >expect <<-EOF &&
-	error: No such branch: ${sq}no-such-branch${sq}
-	fatal: Needed a single revision
+	fatal: No such branch: ${sq}no-such-branch${sq}
 	EOF
 	error_message no-such-branch@{u} 2>actual &&
 	test_i18ncmp expect actual
@@ -156,8 +153,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
 
 test_expect_success '@{u} error message when not on a branch' '
 	cat >expect <<-EOF &&
-	error: HEAD does not point to a branch
-	fatal: Needed a single revision
+	fatal: HEAD does not point to a branch
 	EOF
 	git checkout HEAD^0 &&
 	test_must_fail git rev-parse --verify @{u} 2>actual &&
@@ -166,8 +162,7 @@ test_expect_success '@{u} error message when not on a branch' '
 
 test_expect_success 'branch@{u} error message if upstream branch not fetched' '
 	cat >expect <<-EOF &&
-	error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
-	fatal: Needed a single revision
+	fatal: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
 	EOF
 	error_message bad-upstream@{u} 2>actual &&
 	test_i18ncmp expect actual
-- 
1.8.3.rc3.10.g6f8d616

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-05-24  7:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 10:41 [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Ramkumar Ramachandra
2013-05-21 10:41 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
2013-05-21 16:42   ` Junio C Hamano
2013-05-21 17:56     ` Ramkumar Ramachandra
2013-05-21 18:02       ` Junio C Hamano
2013-05-21 18:04         ` Ramkumar Ramachandra
2013-05-21 18:09           ` Junio C Hamano
2013-05-21 19:19           ` Ramkumar Ramachandra
2013-05-21 20:08             ` Junio C Hamano
2013-05-21 20:14               ` Ramkumar Ramachandra
2013-05-21 20:33                 ` Junio C Hamano
2013-05-21 10:41 ` [PATCH 2/2] sha1_name: fix error message for @{<N>}, @{<date>} Ramkumar Ramachandra
2013-05-21 16:52   ` Junio C Hamano
2013-05-21 17:38     ` Kevin Bracey
2013-05-21 18:09     ` Ramkumar Ramachandra
2013-05-21 16:36 ` [PATCH 0/2] Fix invalid revision error messages for 1.8.3 Junio C Hamano
2013-05-21 17:50   ` Ramkumar Ramachandra
2013-05-21 17:57     ` Junio C Hamano
2013-05-21 18:16       ` Ramkumar Ramachandra
2013-05-22 10:39 [PATCH v2 0/2] Fix invalid revision error messages Ramkumar Ramachandra
2013-05-22 10:39 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra
2013-05-22 17:35   ` Junio C Hamano
2013-05-23 11:03     ` Ramkumar Ramachandra
2013-05-24  7:42 [PATCH v3 0/2] Replacement for rr/die-on-missing-upstream Ramkumar Ramachandra
2013-05-24  7:42 ` [PATCH 1/2] sha1_name: fix error message for @{u} Ramkumar Ramachandra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.