{"thread":{"id":"23032","subject":"[PATCH 1/1] Improve error messages from 'git stash show'","startedAt":"2010-03-15T22:19:50Z","lastAt":"2010-03-16T17:52:37Z","messageCount":5,"participants":["Gustaf Hendeby","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"136888","messageId":"1268691590-27100-1-git-send-email-hendeby@isy.liu.se","threadId":"23032","inReplyTo":null,"subject":"[PATCH 1/1] Improve error messages from 'git stash show'","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2010-03-15T22:19:50Z","receivedAt":"2010-03-15T22:19:50Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":"The previous error message \"fatal: Needed a single revision\" is not\nvery informative.\n\nSigned-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n---\n git-stash.sh |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex aa47e54..cf221c6 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -210,14 +210,18 @@ list_stash () {\n }\n \n show_stash () {\n+\thave_stash || die 'No stash found'\n+\n \tflags=$(git rev-parse --no-revs --flags \"$@\")\n \tif test -z \"$flags\"\n \tthen\n \t\tflags=--stat\n \tfi\n \n-\tw_commit=$(git rev-parse --verify --default $ref_stash \"$@\") &&\n-\tb_commit=$(git rev-parse --verify \"$w_commit^\") &&\n+\tw_commit=$(git rev-parse --quiet --verify --default $ref_stash \"$@\") &&\n+\tb_commit=$(git rev-parse --quiet --verify \"$w_commit^\") ||\n+\t\tdie 'Stash not found'\n+\n \tgit diff $flags $b_commit $w_commit\n }\n \n-- \n1.7.0.2.274.gc376e.dirty\n"},{"id":"136895","messageId":"7vbpepb2e9.fsf@alter.siamese.dyndns.org","threadId":"23032","inReplyTo":"1268691590-27100-1-git-send-email-hendeby@isy.liu.se","subject":"Re: [PATCH 1/1] Improve error messages from 'git stash show'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-15T23:17:50Z","receivedAt":"2010-03-15T23:17:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gustaf Hendeby <hendeby@isy.liu.se> writes:\n\n> The previous error message \"fatal: Needed a single revision\" is not\n> very informative.\n>\n> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n> ---\n>  git-stash.sh |    8 ++++++--\n>  1 files changed, 6 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-stash.sh b/git-stash.sh\n> index aa47e54..cf221c6 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -210,14 +210,18 @@ list_stash () {\n>  }\n>  \n>  show_stash () {\n> +\thave_stash || die 'No stash found'\n> +\n>  \tflags=$(git rev-parse --no-revs --flags \"$@\")\n>  \tif test -z \"$flags\"\n>  \tthen\n>  \t\tflags=--stat\n>  \tfi\n>  \n> -\tw_commit=$(git rev-parse --verify --default $ref_stash \"$@\") &&\n> -\tb_commit=$(git rev-parse --verify \"$w_commit^\") &&\n> +\tw_commit=$(git rev-parse --quiet --verify --default $ref_stash \"$@\") &&\n> +\tb_commit=$(git rev-parse --quiet --verify \"$w_commit^\") ||\n> +\t\tdie 'Stash not found'\n> +\n\nBecause you checked have_stash upfront, an error detected here cannot be\n\"stash not found\".  It is something else, isn't it?\n\n>  \tgit diff $flags $b_commit $w_commit\n>  }\n>  \n> -- \n> 1.7.0.2.274.gc376e.dirty\n"},{"id":"136958","messageId":"4B9F3BAB.10608@isy.liu.se","threadId":"23032","inReplyTo":"7vbpepb2e9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/1] Improve error messages from 'git stash show'","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2010-03-16T08:04:59Z","receivedAt":"2010-03-16T08:04:59Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":"On 03/16/2010 12:17 AM, Junio C Hamano wrote:\n> Gustaf Hendeby <hendeby@isy.liu.se> writes:\n> \n>> The previous error message \"fatal: Needed a single revision\" is not\n>> very informative.\n>>\n>> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n>> ---\n>>  git-stash.sh |    8 ++++++--\n>>  1 files changed, 6 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/git-stash.sh b/git-stash.sh\n>> index aa47e54..cf221c6 100755\n>> --- a/git-stash.sh\n>> +++ b/git-stash.sh\n>> @@ -210,14 +210,18 @@ list_stash () {\n>>  }\n>>  \n>>  show_stash () {\n>> +\thave_stash || die 'No stash found'\n>> +\n>>  \tflags=$(git rev-parse --no-revs --flags \"$@\")\n>>  \tif test -z \"$flags\"\n>>  \tthen\n>>  \t\tflags=--stat\n>>  \tfi\n>>  \n>> -\tw_commit=$(git rev-parse --verify --default $ref_stash \"$@\") &&\n>> -\tb_commit=$(git rev-parse --verify \"$w_commit^\") &&\n>> +\tw_commit=$(git rev-parse --quiet --verify --default $ref_stash \"$@\") &&\n>> +\tb_commit=$(git rev-parse --quiet --verify \"$w_commit^\") ||\n>> +\t\tdie 'Stash not found'\n>> +\n> \n> Because you checked have_stash upfront, an error detected here cannot be\n> \"stash not found\".  It is something else, isn't it?\n\nThis case occurs when you do something like git stash foo, where foo is\nno appropriate stash to show.  Would something like this be more\ninformative in the case of git stash foo:\n\nStash entry 'foo' could not be found\n\n/Gustaf\n"},{"id":"136963","messageId":"7v4okgfbrt.fsf@alter.siamese.dyndns.org","threadId":"23032","inReplyTo":"4B9F3BAB.10608@isy.liu.se","subject":"Re: [PATCH 1/1] Improve error messages from 'git stash show'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-16T16:53:58Z","receivedAt":"2010-03-16T16:53:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gustaf Hendeby <hendeby@isy.liu.se> writes:\n\n> On 03/16/2010 12:17 AM, Junio C Hamano wrote:\n>> Gustaf Hendeby <hendeby@isy.liu.se> writes:\n>> \n>>> The previous error message \"fatal: Needed a single revision\" is not\n>>> very informative.\n>>>\n>>> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n>>> ---\n>>>  git-stash.sh |    8 ++++++--\n>>>  1 files changed, 6 insertions(+), 2 deletions(-)\n>>>\n>>> diff --git a/git-stash.sh b/git-stash.sh\n>>> index aa47e54..cf221c6 100755\n>>> --- a/git-stash.sh\n>>> +++ b/git-stash.sh\n>>> @@ -210,14 +210,18 @@ list_stash () {\n>>>  }\n>>>  \n>>>  show_stash () {\n>>> +\thave_stash || die 'No stash found'\n>>> +\n>>>  \tflags=$(git rev-parse --no-revs --flags \"$@\")\n>>>  \tif test -z \"$flags\"\n>>>  \tthen\n>>>  \t\tflags=--stat\n>>>  \tfi\n>>>  \n>>> -\tw_commit=$(git rev-parse --verify --default $ref_stash \"$@\") &&\n>>> -\tb_commit=$(git rev-parse --verify \"$w_commit^\") &&\n>>> +\tw_commit=$(git rev-parse --quiet --verify --default $ref_stash \"$@\") &&\n>>> +\tb_commit=$(git rev-parse --quiet --verify \"$w_commit^\") ||\n>>> +\t\tdie 'Stash not found'\n>>> +\n>> \n>> Because you checked have_stash upfront, an error detected here cannot be\n>> \"stash not found\".  It is something else, isn't it?\n>\n> This case occurs when you do something like git stash foo, where foo is\n> no appropriate stash to show.  Would something like this be more\n> informative in the case of git stash foo:\n>\n> Stash entry 'foo' could not be found\n\nThat is more like \"'foo' is not a stash\", isn't it?\n"},{"id":"299174","messageId":"1268761957-9769-1-git-send-email-hendeby@isy.liu.se","threadId":"23032","inReplyTo":"7v4okgfbrt.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] Improve error messages from 'git stash show'","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2010-03-16T17:52:37Z","receivedAt":"2010-03-16T17:52:37Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":"The previous error message \"fatal: Needed a single revision\" is not\nvery informative.\n\nSigned-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n---\n\nOn 03/16/2010 05:53 PM, Junio C Hamano wrote:\n>>>> +\tb_commit=$(git rev-parse --quiet --verify \"$w_commit^\") ||\n>>>> >>>  +\t\tdie 'Stash not found'\n>>>> >>>  +\n>>> >>  \n>>> >>  Because you checked have_stash upfront, an error detected here cannot be\n>>> >>  \"stash not found\".  It is something else, isn't it?\n>> >\n>> >  This case occurs when you do something like git stash foo, where foo is\n>> >  no appropriate stash to show.  Would something like this be more\n>> >  informative in the case of git stash foo:\n>> >\n>> >  Stash entry 'foo' could not be found\n> That is more like \"'foo' is not a stash\", isn't it?\n\nI find your suggestion much clearer.  Thank you!\n\n/Gustaf\n\n git-stash.sh |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex aa47e54..59db3dc 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -210,14 +210,18 @@ list_stash () {\n }\n \n show_stash () {\n+\thave_stash || die 'No stash found'\n+\n \tflags=$(git rev-parse --no-revs --flags \"$@\")\n \tif test -z \"$flags\"\n \tthen\n \t\tflags=--stat\n \tfi\n \n-\tw_commit=$(git rev-parse --verify --default $ref_stash \"$@\") &&\n-\tb_commit=$(git rev-parse --verify \"$w_commit^\") &&\n+\tw_commit=$(git rev-parse --quiet --verify --default $ref_stash \"$@\") &&\n+\tb_commit=$(git rev-parse --quiet --verify \"$w_commit^\") ||\n+\t\tdie \"'$*' is not a stash\"\n+\n \tgit diff $flags $b_commit $w_commit\n }\n \n-- \n1.7.0.2.274.gba5d.dirty\n\n"}]}