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

Re: [PATCH] Allow stashes to be referenced by index only

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 25, 2016, 21:41 UTC
Message-ID
<xmqqshrkqf79.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1477352413-4628-1-git-send-email-watsona4@gmail.com>
Aaron M Watson <watsona4@gmail.com> writes:
Aaron M Watson <watsona4@gmail.com> writes:
> Instead of referencing "stash@{n}" explicitly, it can simply be
> referenced as "n".
> Most users only reference stashes by their position
> in the stash stask (what I refer to as the "index").

It is unclear if the first sentence is a statement of the fact, an expression of desire, or something else. With the current codebase, it cannot simply be referenced as "n", and you either "wish it were possible", or "make it possible to do so", or perhaps little bit of both.

This is why we tend to use imperative mood to give an order to the codebase to "be like so" to make it clear.

Perhaps
  Instead of referencing "stash@{n}" explicitly, make it possible to
  simply reference as "n".  Most users only reference stashes by their
  position in the stash stask (what I refer to as the "index" here).

or something like that (which is what I tenatively rewritten this to while queuing).

Show 22 quoted lines
> @@ -404,6 +403,9 @@ parse_flags_and_rev()
>  					die "$(eval_gettext "unknown option: \$opt")"
>  				FLAGS="${FLAGS}${FLAGS:+ }$opt"
>  			;;
> +			*)
> +				REV="${REV}${REV:+ }'$opt'"
> +			;;
>  		esac
>  	done
>  
> @@ -422,6 +424,15 @@ parse_flags_and_rev()
>  		;;
>  	esac
>  
> +	case "$1" in
> +		*[!0-9]*)
> +			:
> +		;;
> +		*)
> +			set -- "${ref_stash}@{$1}"
> +		;;
> +	esac

I can see that you inherited the brokenness from an existing one in the earlier hunk, but case arms in these two case statements are indented one level too deep. It would be good to fix it in a follow-up patch (not a reroll of this patch).

Thanks.  Will queue.
Previous: Aaron and Ashley WatsonNext: Ramsay Jones
Message 6 of 8 in “Allow stashes to be referenced by index only”
  1. Allow stashes to be referenced by index onlyAaron M Watson, Sep 8, 2016
  2. Jeff KingOct 23, 2016
  3. Allow stashes to be referenced by index onlyAaron M Watson, Oct 24, 2016
  4. Jeff KingOct 25, 2016
  5. Aaron and Ashley WatsonOct 25, 2016
  6. Junio C HamanoOct 25, 2016
  7. Ramsay JonesOct 26, 2016
  8. Jeff KingOct 24, 2016

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.