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

[PATCH v2] request-pull: improve error message for invalid revision args

From
DWDirk Wallenstein <halsmit@t-online.de>
Date
Jul 17, 2013, 17:28 UTC
Message-ID
<20130717172811.GA12981@bottich>
In-Reply-To
<7vr4ex6rqq.fsf@alter.siamese.dyndns.org>
Currently, when an invalid revision is specified, the error message is:
    fatal: Needed a single revision

This is misleading because, you might think there is something wrong with the command line as a whole.

Now the user gets a more meaningful error message, showing the invalid revision.

Signed-off-by: Dirk Wallenstein <halsmit@t-online.de>
---
On Wed, Jul 17, 2013 at 10:06:21AM -0700, Junio C Hamano wrote:
> Dirk Wallenstein <halsmit@t-online.de> writes:
> > +baserev=$(git rev-parse --verify "$base"^0 2>/dev/null)
> 
> Use "--quiet" instead?
Oh, of course.
 git-request-pull.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/git-request-pull.sh b/git-request-pull.sh
index d566015..ebf1269 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -51,8 +51,18 @@ fi
 tag_name=$(git describe --exact "$head^0" 2>/dev/null)
 
 test -n "$base" && test -n "$url" || usage
-baserev=$(git rev-parse --verify "$base"^0) &&
-headrev=$(git rev-parse --verify "$head"^0) || exit
+
+baserev=$(git rev-parse --verify --quiet "$base"^0)
+if test -z "$baserev"
+then
+    die "fatal: Not a valid revision: $base"
+fi
+
+headrev=$(git rev-parse --verify --quiet "$head"^0)
+if test -z "$headrev"
+then
+    die "fatal: Not a valid revision: $head"
+fi
 
 merge_base=$(git merge-base $baserev $headrev) ||
 die "fatal: No commits in common between $base and $head"
-- 
1.8.3.3.2.g85103ba
Previous: Junio C Hamano
Message 3 of 3 in “request-pull: improve error message for invalid revision args”
  1. request-pull: improve error message for invalid revision argsDirk Wallenstein, Jul 16, 2013
  2. Junio C HamanoJul 17, 2013
  3. request-pull: improve error message for invalid revision argsDirk Wallenstein, Jul 17, 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.