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

Re: [PATCH 3/6] stash: simplify option parser for create

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2013, 14:34 UTC
Message-ID
<7vfvxrosnf.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1368449154-21882-4-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> The option parser for create unnecessarily checks "$1" inside a case
> statement that matches "$1" in the first place.  Also, use "$@", not
> "$*", as our caller is expecting "$1" "$2", not "$1c$2" (where c is the
> first character of IFS).

The first part of the patch may be OK but the rest unfortunately is wrong.

The semi-user facing "git stash create" never was meant to take anything but a message sentence and "$*" is the proper way to say "everything is meant for a single message (just like echo)". Changing it to "$@" will change the semantics in a big way.

Show 23 quoted lines
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  git-stash.sh | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/git-stash.sh b/git-stash.sh
> index bbefdf6..0ede313 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -546,11 +546,8 @@ clear)
>  	clear_stash "$@"
>  	;;
>  create)
> -	if test $# -gt 0 && test "$1" = create
> -	then
> -		shift
> -	fi
> -	create_stash "$*" && echo "$w_commit"
> +	shift
> +	create_stash "$@" && echo "$w_commit"
>  	;;
>  drop)
>  	shift
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 5 of 21 in “Get stash to help rebase.autostash”
  1. 0/6 Get stash to help rebase.autostashRamkumar Ramachandra, May 13, 2013
  2. 1/6 Documentation/stash: correct synopsis for createRamkumar Ramachandra, May 13, 2013
  3. 2/6 Documentation/stash: document short form -p in synopsisRamkumar Ramachandra, May 13, 2013
  4. 3/6 stash: simplify option parser for createRamkumar Ramachandra, May 13, 2013
  5. Junio C HamanoMay 13, 2013
  6. Ramkumar RamachandraMay 13, 2013
  7. 4/6 stash: introduce 'git stash store'Ramkumar Ramachandra, May 13, 2013
  8. Junio C HamanoMay 13, 2013
  9. Ramkumar RamachandraMay 13, 2013
  10. Junio C HamanoMay 13, 2013
  11. Ramkumar RamachandraMay 13, 2013
  12. Junio C HamanoMay 13, 2013
  13. Ramkumar RamachandraMay 13, 2013
  14. Junio C HamanoMay 13, 2013
  15. Ramkumar RamachandraMay 13, 2013
  16. Junio C HamanoMay 13, 2013
  17. Ramkumar RamachandraMay 13, 2013
  18. Ramkumar RamachandraMay 13, 2013
  19. 5/6 stash: tweak error message in store_stash ()Ramkumar Ramachandra, May 13, 2013
  20. Junio C HamanoMay 13, 2013
  21. 6/6 rebase: use 'git stash store' to simplify logicRamkumar Ramachandra, May 13, 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.