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

Re: [PATCH] stash: handle specifying stashes with spaces

From
Thomas Rast <tr@thomasrast.ch>
Date
Nov 29, 2013, 19:54 UTC
Message-ID
<87k3frdlwc.fsf@thomasrast.ch>
In-Reply-To
<1385752979-28162-1-git-send-email-oystwa@gmail.com>
Øystein Walle <oystwa@gmail.com> writes:
Show 9 quoted lines
> When trying to pop/apply a stash specified with an argument containing
> spaces the user will see an error:
>
>     $ git stash pop 'stash@{two hours ago}'
>     Too many revisions specified: stash@{two hours ago}
>
> This happens because word splitting is used to count non-option
> arguments. Instead shift the positional arguments as the options are
> processed; the number of arguments left is then the number we're after.
[...]
Show 20 quoted lines
>  	for opt
>  	do
>  		case "$opt" in
>  			-q|--quiet)
>  				GIT_QUIET=-t
> +				shift
>  			;;
>  			--index)
>  				INDEX_OPTION=--index
> +				shift
>  			;;
>  			-*)
>  				FLAGS="${FLAGS}${FLAGS:+ }$opt"
> +				shift
>  			;;
>  		esac
>  	done
>  
> -	set -- $REV
> -

But this isn't correct any more, is it? You unconditionally shift off arguments when you see something of the form -*, even if what you shift is not what you're currently looking at.

For example, without this patch:
  $ g stash apply stash@{0} --index
  On branch next
  Your branch is ahead of 'origin/next' by 41 commits.
    (use "git push" to publish your local commits)
  [blah blah]
but with this patch:
  $ g stash apply stash@{0} --index
  --index is not valid reference

Granted, git-stash is extremely inconsistent in its handling of options. For example, 'git stash save foo -k' does _not_ treat -k as an option. If you set out to unify this (not just randomly (un)break one subroutine) I'd be all for it.

-- 
Thomas Rast
tr@thomasrast.ch
Previous: Øystein WalleNext: Øystein Walle
Message 2 of 6 in “stash: handle specifying stashes with spaces”
  1. stash: handle specifying stashes with spacesØystein Walle, Nov 29, 2013
  2. Thomas RastNov 29, 2013
  3. stash: handle specifying stashes with spacesØystein Walle, Nov 29, 2013
  4. Thomas RastNov 29, 2013
  5. Øystein WalleNov 30, 2013
  6. Eric SunshineDec 1, 2013

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.