Re: [PATCH] git stash: Give friendlier errors when there is nothing to apply

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Junio C Hamano <gitster@xxxxxxxxx>

> Ori Avtalion <ori@xxxxxxxxxxxxx> writes:
>
>> The change makes sure a stash (given or default) exists before
>> checking if the working tree is dirty.
>>
>> If the default stash is requested, the old message was scary and
>> included a 'fatal' error from rev-parse:
>>      fatal: Needed a single revision
>>      : no valid stashed state found
>>
>> It is replaced with a friendlier 'Nothing to apply' error, similar to
>> 'git stash branch'.
>>
>> If a specific stash is specified, the 'Needed a single revision' errors
>> from rev-parse are suppressed.
>>
>> Signed-off-by: Ori Avtalion <ori@xxxxxxxxxxxxx>
>> Acked-by: Thomas Rast <trast@xxxxxxxxxxxxxxx>
>
> I do not see anything that might break existing usage of the command.
> Comments?

The patch looks good to me. I think it was my fault but you can avoid 
adding two extra --quiet by inspecting i_tree (in other words, "$s^2:") 
before w_tree and b_tree. Because a commit that is a stash exactly has 
two parents, it may be good to also make sure 'git rev-parse "$s^3"' 
fails.

	s=$(git rev-parse --verify --default $ref_stash "$@") &&
	! git rev-parse --quiet --verify "$s^3" >/dev/null &&
	i_tree=$(git rev-parse --quiet --verify "$s^2:") &&
	b_tree=$(git rev-parse --verify "$s^1:") &&
	w_tree=$(git rev-parse --verify "$s:") ||
		die "$*: no valid stashed state found"

> A tangent; we might want an analogue to "shortlog -s -n" but based on
> "blame".

I'm sorry, I don't understand what you mean.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]