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

Re: Better usability of stash refs

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 19, 2017, 20:49 UTC
Message-ID
<xmqqd19zsnxw.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAHd499C8x_zWJyRNXO-410gxudk897-okJaA3uOPYr38QNHjpA@mail.gmail.com>
Robert Dailey <rcdailey.lists@gmail.com> writes:
Show 16 quoted lines
> 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")"
	}
Previous: Robert DaileyNext: Jeff King
Message 2 of 4 in “Better usability of stash refs”
  1. Robert DaileyJun 19, 2017
  2. Junio C HamanoJun 19, 2017
  3. Jeff KingJun 19, 2017
  4. Robert DaileyJun 20, 2017

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.