git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] request-pull: improve error message for invalid revision args
@ 2013-07-16 10:46 Dirk Wallenstein
  2013-07-17 17:06 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Dirk Wallenstein @ 2013-07-16 10:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Shawn O. Pearce

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

Notes:
    I assume, it is not worth the trouble to even try to change the message from
    rev-parse for this.  People might parse the messages, which is probably why
    this message still exists.

 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..f38f0f9 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 "$base"^0 2>/dev/null)
+if test -z "$baserev"
+then
+    die "fatal: Not a valid revision: $base"
+fi
+
+headrev=$(git rev-parse --verify "$head"^0 2>/dev/null)
+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.2.51.g8658a4c

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

* Re: [PATCH] request-pull: improve error message for invalid revision args
  2013-07-16 10:46 [PATCH] request-pull: improve error message for invalid revision args Dirk Wallenstein
@ 2013-07-17 17:06 ` Junio C Hamano
  2013-07-17 17:28   ` [PATCH v2] " Dirk Wallenstein
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2013-07-17 17:06 UTC (permalink / raw)
  To: Dirk Wallenstein; +Cc: git, Shawn O. Pearce

Dirk Wallenstein <halsmit@t-online.de> writes:

> 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>
> ---
>
> Notes:
>     I assume, it is not worth the trouble to even try to change the message from
>     rev-parse for this.  People might parse the messages, which is probably why
>     this message still exists.

You are right---such a change will break existing scripts, so it is
not just "not worth the trouble" but is actively wrong to change the
error message.

>  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..f38f0f9 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 "$base"^0 2>/dev/null)

Use "--quiet" instead?

> +if test -z "$baserev"
> +then
> +    die "fatal: Not a valid revision: $base"
> +fi
> +
> +headrev=$(git rev-parse --verify "$head"^0 2>/dev/null)
> +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"

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

* [PATCH v2] request-pull: improve error message for invalid revision args
  2013-07-17 17:06 ` Junio C Hamano
@ 2013-07-17 17:28   ` Dirk Wallenstein
  0 siblings, 0 replies; 3+ messages in thread
From: Dirk Wallenstein @ 2013-07-17 17:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Shawn O. Pearce

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

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

end of thread, other threads:[~2013-07-17 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-16 10:46 [PATCH] request-pull: improve error message for invalid revision args Dirk Wallenstein
2013-07-17 17:06 ` Junio C Hamano
2013-07-17 17:28   ` [PATCH v2] " Dirk Wallenstein

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).