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