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

Re: stash --dwim safety

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Sep 1, 2009, 06:27 UTC
Message-ID
<vpqocpv2n93.fsf@bauges.imag.fr>
In-Reply-To
<7v3a77dx5b.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> It turns out that the rework was simple enough, so I did it myself.  Among
> his 3 patch series, an equivalent to the first one ("save -keep" can be
> written as "save -k" for brevity) were already in, and the second one
> (default to "save" if we see any option before command word) was unsafe
> without the third one (reject unknown option to "save"), so it ended up as
> a single patch that is a combination of the latter two patches.
Thanks, lack of time on my side to work on this, sorry.

I was actually thinking of being a little more paranoid to prevent accidental "stash save": we could refuse to create a named stash when the "save" command is not given. The case I hadn't thought of was "git stash -q apply", which has 99% chances of being a typo for "git stash apply -q", and which would mean "create a stash named apply, quietly".

Show 6 quoted lines
> +# The default command is "save"
> +case "$1" in
> +-*)
> +	set "save" "$@"
> +	;;
> +esac
So, that could become something like
default_to_save=t
for arg in "$@"; do
	case "$arg" in
	-*)
		;;
	*)
		default_to_save=
	esac
done
if [ "$default_to_save" = t ]; then
	set "save" "$@"
fi
(untested)
-- 
Matthieu
Previous: Junio C HamanoNext: Jeff King
Message 4 of 16 in “What's cooking in git.git (Aug 2009, #06; Sun, 30)”
  1. Junio C HamanoAug 31, 2009
  2. Johan HerlandAug 31, 2009
  3. stash --dwim safety (was Re: What's cooking in git.git (Aug 2009, #06; Sun, 30))Junio C Hamano, Sep 1, 2009
  4. Matthieu MoySep 1, 2009
  5. Jeff KingSep 1, 2009
  6. Junio C HamanoSep 2, 2009
  7. Jeff KingSep 2, 2009
  8. Johannes SchindelinSep 2, 2009
  9. Matthieu MoySep 2, 2009
  10. Peter KreftingSep 1, 2009
  11. Jakub NarebskiSep 1, 2009
  12. Junio C HamanoSep 1, 2009
  13. Jakub NarebskiSep 2, 2009
  14. Peter HarrisSep 2, 2009
  15. Nick EdelenSep 1, 2009
  16. Junio C HamanoSep 2, 2009

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.