All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: stash --dwim safety
Date: Tue, 01 Sep 2009 08:27:20 +0200	[thread overview]
Message-ID: <vpqocpv2n93.fsf@bauges.imag.fr> (raw)
In-Reply-To: <7v3a77dx5b.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Mon\, 31 Aug 2009 22\:58\:08 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> 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".

> +# 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

  reply	other threads:[~2009-09-01  6:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-31  7:03 What's cooking in git.git (Aug 2009, #06; Sun, 30) Junio C Hamano
2009-08-31  9:32 ` Johan Herland
2009-09-01  5:58 ` stash --dwim safety (was Re: What's cooking in git.git (Aug 2009, #06; Sun, 30)) Junio C Hamano
2009-09-01  6:27   ` Matthieu Moy [this message]
2009-09-01  6:57     ` stash --dwim safety Jeff King
2009-09-02  4:11       ` Junio C Hamano
2009-09-02  4:59         ` Jeff King
2009-09-02  6:48           ` Johannes Schindelin
2009-09-02  6:26         ` Matthieu Moy
2009-09-01 15:08 ` What's cooking in git.git (Aug 2009, #06; Sun, 30) Peter Krefting
2009-09-01 16:47 ` Jakub Narebski
2009-09-01 16:51   ` Junio C Hamano
2009-09-02 17:44     ` Jakub Narebski
2009-09-02 18:16     ` Peter Harris
2009-09-01 22:25 ` Nick Edelen
2009-09-02  5:32   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vpqocpv2n93.fsf@bauges.imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.