git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] Improve error messages from 'git stash show'
@ 2010-03-15 22:19 Gustaf Hendeby
  2010-03-15 23:17 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Gustaf Hendeby @ 2010-03-15 22:19 UTC (permalink / raw)
  To: git; +Cc: gitster, Gustaf Hendeby

The previous error message "fatal: Needed a single revision" is not
very informative.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
---
 git-stash.sh |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index aa47e54..cf221c6 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -210,14 +210,18 @@ list_stash () {
 }
 
 show_stash () {
+	have_stash || die 'No stash found'
+
 	flags=$(git rev-parse --no-revs --flags "$@")
 	if test -z "$flags"
 	then
 		flags=--stat
 	fi
 
-	w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
-	b_commit=$(git rev-parse --verify "$w_commit^") &&
+	w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
+	b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
+		die 'Stash not found'
+
 	git diff $flags $b_commit $w_commit
 }
 
-- 
1.7.0.2.274.gc376e.dirty

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

* Re: [PATCH 1/1] Improve error messages from 'git stash show'
  2010-03-15 22:19 [PATCH 1/1] Improve error messages from 'git stash show' Gustaf Hendeby
@ 2010-03-15 23:17 ` Junio C Hamano
  2010-03-16  8:04   ` Gustaf Hendeby
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2010-03-15 23:17 UTC (permalink / raw)
  To: Gustaf Hendeby; +Cc: git

Gustaf Hendeby <hendeby@isy.liu.se> writes:

> The previous error message "fatal: Needed a single revision" is not
> very informative.
>
> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
> ---
>  git-stash.sh |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/git-stash.sh b/git-stash.sh
> index aa47e54..cf221c6 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -210,14 +210,18 @@ list_stash () {
>  }
>  
>  show_stash () {
> +	have_stash || die 'No stash found'
> +
>  	flags=$(git rev-parse --no-revs --flags "$@")
>  	if test -z "$flags"
>  	then
>  		flags=--stat
>  	fi
>  
> -	w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
> -	b_commit=$(git rev-parse --verify "$w_commit^") &&
> +	w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
> +	b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
> +		die 'Stash not found'
> +

Because you checked have_stash upfront, an error detected here cannot be
"stash not found".  It is something else, isn't it?

>  	git diff $flags $b_commit $w_commit
>  }
>  
> -- 
> 1.7.0.2.274.gc376e.dirty

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

* Re: [PATCH 1/1] Improve error messages from 'git stash show'
  2010-03-15 23:17 ` Junio C Hamano
@ 2010-03-16  8:04   ` Gustaf Hendeby
  2010-03-16 16:53     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Gustaf Hendeby @ 2010-03-16  8:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 03/16/2010 12:17 AM, Junio C Hamano wrote:
> Gustaf Hendeby <hendeby@isy.liu.se> writes:
> 
>> The previous error message "fatal: Needed a single revision" is not
>> very informative.
>>
>> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
>> ---
>>  git-stash.sh |    8 ++++++--
>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/git-stash.sh b/git-stash.sh
>> index aa47e54..cf221c6 100755
>> --- a/git-stash.sh
>> +++ b/git-stash.sh
>> @@ -210,14 +210,18 @@ list_stash () {
>>  }
>>  
>>  show_stash () {
>> +	have_stash || die 'No stash found'
>> +
>>  	flags=$(git rev-parse --no-revs --flags "$@")
>>  	if test -z "$flags"
>>  	then
>>  		flags=--stat
>>  	fi
>>  
>> -	w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
>> -	b_commit=$(git rev-parse --verify "$w_commit^") &&
>> +	w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
>> +	b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
>> +		die 'Stash not found'
>> +
> 
> Because you checked have_stash upfront, an error detected here cannot be
> "stash not found".  It is something else, isn't it?

This case occurs when you do something like git stash foo, where foo is
no appropriate stash to show.  Would something like this be more
informative in the case of git stash foo:

Stash entry 'foo' could not be found

/Gustaf

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

* Re: [PATCH 1/1] Improve error messages from 'git stash show'
  2010-03-16  8:04   ` Gustaf Hendeby
@ 2010-03-16 16:53     ` Junio C Hamano
  2010-03-16 17:52       ` [PATCH v2] " Gustaf Hendeby
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2010-03-16 16:53 UTC (permalink / raw)
  To: Gustaf Hendeby; +Cc: Junio C Hamano, git

Gustaf Hendeby <hendeby@isy.liu.se> writes:

> On 03/16/2010 12:17 AM, Junio C Hamano wrote:
>> Gustaf Hendeby <hendeby@isy.liu.se> writes:
>> 
>>> The previous error message "fatal: Needed a single revision" is not
>>> very informative.
>>>
>>> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
>>> ---
>>>  git-stash.sh |    8 ++++++--
>>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/git-stash.sh b/git-stash.sh
>>> index aa47e54..cf221c6 100755
>>> --- a/git-stash.sh
>>> +++ b/git-stash.sh
>>> @@ -210,14 +210,18 @@ list_stash () {
>>>  }
>>>  
>>>  show_stash () {
>>> +	have_stash || die 'No stash found'
>>> +
>>>  	flags=$(git rev-parse --no-revs --flags "$@")
>>>  	if test -z "$flags"
>>>  	then
>>>  		flags=--stat
>>>  	fi
>>>  
>>> -	w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
>>> -	b_commit=$(git rev-parse --verify "$w_commit^") &&
>>> +	w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
>>> +	b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
>>> +		die 'Stash not found'
>>> +
>> 
>> Because you checked have_stash upfront, an error detected here cannot be
>> "stash not found".  It is something else, isn't it?
>
> This case occurs when you do something like git stash foo, where foo is
> no appropriate stash to show.  Would something like this be more
> informative in the case of git stash foo:
>
> Stash entry 'foo' could not be found

That is more like "'foo' is not a stash", isn't it?

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

* [PATCH v2] Improve error messages from 'git stash show'
  2010-03-16 16:53     ` Junio C Hamano
@ 2010-03-16 17:52       ` Gustaf Hendeby
  0 siblings, 0 replies; 5+ messages in thread
From: Gustaf Hendeby @ 2010-03-16 17:52 UTC (permalink / raw)
  To: Junio C Hamano, Junio C Hamano; +Cc: git, Gustaf Hendeby

The previous error message "fatal: Needed a single revision" is not
very informative.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
---

On 03/16/2010 05:53 PM, Junio C Hamano wrote:
>>>> +	b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
>>>> >>>  +		die 'Stash not found'
>>>> >>>  +
>>> >>  
>>> >>  Because you checked have_stash upfront, an error detected here cannot be
>>> >>  "stash not found".  It is something else, isn't it?
>> >
>> >  This case occurs when you do something like git stash foo, where foo is
>> >  no appropriate stash to show.  Would something like this be more
>> >  informative in the case of git stash foo:
>> >
>> >  Stash entry 'foo' could not be found
> That is more like "'foo' is not a stash", isn't it?

I find your suggestion much clearer.  Thank you!

/Gustaf

 git-stash.sh |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index aa47e54..59db3dc 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -210,14 +210,18 @@ list_stash () {
 }
 
 show_stash () {
+	have_stash || die 'No stash found'
+
 	flags=$(git rev-parse --no-revs --flags "$@")
 	if test -z "$flags"
 	then
 		flags=--stat
 	fi
 
-	w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
-	b_commit=$(git rev-parse --verify "$w_commit^") &&
+	w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
+	b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
+		die "'$*' is not a stash"
+
 	git diff $flags $b_commit $w_commit
 }
 
-- 
1.7.0.2.274.gba5d.dirty


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

end of thread, other threads:[~2010-03-16 17:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 22:19 [PATCH 1/1] Improve error messages from 'git stash show' Gustaf Hendeby
2010-03-15 23:17 ` Junio C Hamano
2010-03-16  8:04   ` Gustaf Hendeby
2010-03-16 16:53     ` Junio C Hamano
2010-03-16 17:52       ` [PATCH v2] " Gustaf Hendeby

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 NNTP newsgroup(s).