Git development
 help / color / mirror / Atom feed
* Better usability of stash refs
@ 2017-06-19 20:32 Robert Dailey
  2017-06-19 20:49 ` Junio C Hamano
  2017-06-19 20:56 ` Jeff King
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Dailey @ 2017-06-19 20:32 UTC (permalink / raw)
  To: Git

To drop a stash, I have to do this (example):

$ git stash drop stash@{3}

Using the full "stash@{N}" seems superfluous since the documentation
states it must be a stash in the first place. It would make more sense
(and be quicker to type) to do:

$ git stash drop 3

Is there a trick I can use to make this shorthand possible? I thought
about creating a "s" script for "stash" that intercepted the
parameters for only a couple of stash sub-commands and created the
ref, but that seems a lot of work.

Any productivity tips here? Thanks in advance.

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

* Re: Better usability of stash refs
  2017-06-19 20:32 Better usability of stash refs Robert Dailey
@ 2017-06-19 20:49 ` Junio C Hamano
  2017-06-19 20:56 ` Jeff King
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2017-06-19 20:49 UTC (permalink / raw)
  To: Robert Dailey; +Cc: Git

Robert Dailey <rcdailey.lists@gmail.com> writes:

> To drop a stash, I have to do this (example):
>
> $ git stash drop stash@{3}
>
> Using the full "stash@{N}" seems superfluous since the documentation
> states it must be a stash in the first place. It would make more sense
> (and be quicker to type) to do:
>
> $ git stash drop 3
>
> Is there a trick I can use to make this shorthand possible? I thought
> about creating a "s" script for "stash" that intercepted the
> parameters for only a couple of stash sub-commands and created the
> ref, but that seems a lot of work.
>
> Any productivity tips here? Thanks in advance.

Isn't that already the case?

git-stash.sh::drop_stash gives "$@" to assert_stash_ref, which in
turn calls is_stash_ref, which in turn calls is_stash_like, and this
callchain eventually cals into parse_flags_and_rev.  Which has this
bit (may be hard to read because it is incorrectly indented):

	case "$1" in
		*[!0-9]*)
			:
		;;
		*)
			set -- "${ref_stash}@{$1}"
		;;
	esac

	REV=$(git rev-parse --symbolic --verify --quiet "$1") || {
		reference="$1"
		die "$(eval_gettext "\$reference is not a valid reference")"
	}


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

* Re: Better usability of stash refs
  2017-06-19 20:32 Better usability of stash refs Robert Dailey
  2017-06-19 20:49 ` Junio C Hamano
@ 2017-06-19 20:56 ` Jeff King
  2017-06-20 13:46   ` Robert Dailey
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff King @ 2017-06-19 20:56 UTC (permalink / raw)
  To: Robert Dailey; +Cc: Junio C Hamano, Git

On Mon, Jun 19, 2017 at 03:32:54PM -0500, Robert Dailey wrote:

> To drop a stash, I have to do this (example):
> 
> $ git stash drop stash@{3}
> 
> Using the full "stash@{N}" seems superfluous since the documentation
> states it must be a stash in the first place. It would make more sense
> (and be quicker to type) to do:
> 
> $ git stash drop 3
> 
> Is there a trick I can use to make this shorthand possible? I thought
> about creating a "s" script for "stash" that intercepted the
> parameters for only a couple of stash sub-commands and created the
> ref, but that seems a lot of work.
> 
> Any productivity tips here? Thanks in advance.

Junio mentioned that this is already possible. I suspect the problem may
be that your Git is not recent enough. It was added in a56c8f5aa (stash:
allow stashes to be referenced by index only, 2016-10-24), which is in
v2.11.0.

-Peff

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

* Re: Better usability of stash refs
  2017-06-19 20:56 ` Jeff King
@ 2017-06-20 13:46   ` Robert Dailey
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dailey @ 2017-06-20 13:46 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, Git

On Mon, Jun 19, 2017 at 3:56 PM, Jeff King <peff@peff.net> wrote:
> On Mon, Jun 19, 2017 at 03:32:54PM -0500, Robert Dailey wrote:
>
>> To drop a stash, I have to do this (example):
>>
>> $ git stash drop stash@{3}
>>
>> Using the full "stash@{N}" seems superfluous since the documentation
>> states it must be a stash in the first place. It would make more sense
>> (and be quicker to type) to do:
>>
>> $ git stash drop 3
>>
>> Is there a trick I can use to make this shorthand possible? I thought
>> about creating a "s" script for "stash" that intercepted the
>> parameters for only a couple of stash sub-commands and created the
>> ref, but that seems a lot of work.
>>
>> Any productivity tips here? Thanks in advance.
>
> Junio mentioned that this is already possible. I suspect the problem may
> be that your Git is not recent enough. It was added in a56c8f5aa (stash:
> allow stashes to be referenced by index only, 2016-10-24), which is in
> v2.11.0.
>
> -Peff

Thanks guys. Actually I'm running 2.13, I just haven't tried it since
way before 2.11. I always assumed it wasn't working like I expected
since last time I tried it. Yesterday I just happened to remember that
this would be nice to have, so I wrote the email but didn't bother
testing it on the newest version first. Sorry about that.

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

end of thread, other threads:[~2017-06-20 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-19 20:32 Better usability of stash refs Robert Dailey
2017-06-19 20:49 ` Junio C Hamano
2017-06-19 20:56 ` Jeff King
2017-06-20 13:46   ` Robert Dailey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox