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

Re: [PATCH] Replace the cryptic messages from "git stash show".

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 15, 2007, 06:12 UTC
Message-ID
<7v63z0o59r.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20071215051425.GA9118@fawkes>
Jing Xue <jingxue@digizenstudio.com> writes:
Show 49 quoted lines
> On Thu, Dec 13, 2007 at 05:34:40PM -0800, Junio C Hamano wrote:
>> 
>> I agree "git stash show" should not give cryptic error message, but I
>> think you should do this only when the user did not explicitly say which
>> stash to show (that is, we should still give error message if the user
>> said "git stash show garbage").
>
> Good point. Actually I found out that if there _are_ some stashes and an
> invalid name is given, the current behavior is still printing
> refs/stash, which I think is not quite right. So I also try to fix that
> while I'm at it.
>
> Now "git stash show" will keep quiet and just exit if there are no
> stashes at all. "git stash show some-non-existent-stash" will always
> print a clear message indicating the case.
>
> ---
>  git-stash.sh |   23 ++++++++++++++++++++---
>  1 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/git-stash.sh b/git-stash.sh
> index f16fd9c..40e93dd 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -116,13 +116,30 @@ show_stash () {
>  	flags=$(git rev-parse --no-revs --flags "$@")
>  	if test -z "$flags"
>  	then
> -		flags=--stat
> +		diff_flags=--stat
> +	else
> +		diff_flags=$flags
> +	fi
> +	s=$(git rev-parse --revs-only --no-flags "$@")
> +	if test -z "$s"
> +	then
> +		arguments=$@
> +		if test "${flags}" = "${arguments}"
> +		then
> +			s=$(git rev-parse --revs-only --no-flags $ref_stash)
> +			if test -z "$s"
> +			then
> +				return 0
> +			fi
> +		else
> +			eval stash_name=\$$#
> +			die "Can't find any stash with name $stash_name"
> +		fi
>  	fi

Is it just me who feels that the added code is much worse than the disease?

Previous: Jing XueNext: Jing Xue
Message 4 of 5 in “Makes 'git-stash show' stay quiet when there are no stashes.”
  1. Makes 'git-stash show' stay quiet when there are no stashes.Jing Xue, Dec 14, 2007
  2. Junio C HamanoDec 14, 2007
  3. Replace the cryptic messages from "git stash show".Jing Xue, Dec 15, 2007
  4. Junio C HamanoDec 15, 2007
  5. Jing XueDec 15, 2007

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.