sha1_name: fix error message for @{u}
commit17bf4ff3cd3d7fd4b252b81417df8be1b3b2b128
authorRamkumar Ramachandra <artagnon@gmail.com>
Wed, 22 May 2013 10:39:54 +0000 (22 16:09 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 May 2013 19:46:02 +0000 (22 12:46 -0700)
treed4adde5716b5544b6d60259dd1fa36fec30a35fe
parent9134a460e3ebfc93790e98d74b3cda2bcca8eb8b
sha1_name: fix error message for @{u}

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.

This only turns error() that may be called after we know we are
dealing with an @{upstream} marker into die(), without touching
silent error returns "return -1" from the function.  Any caller that
wants to handle an error condition itself will not be hurt by this
change, unless they want to see the message from error() and then
exit silently without giving its own message, which needs to be
fixed anyway.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
t/t1507-rev-parse-upstream.sh