git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: JM Ibanez <jm@orangeandbronze.com>
Cc: Jeff King <peff@peff.net>, Brandon Casey <casey@nrlssc.navy.mil>,
	Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] git-stash clear: refuse to work with extra parameter for now
Date: Sat, 05 Jan 2008 01:35:54 -0800	[thread overview]
Message-ID: <7vy7b4bon9.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <871w8woc77.fsf@adler.orangeandbronze.com> (JM Ibanez's message of "Sat, 05 Jan 2008 17:26:20 +0800")

Because it is so tempting to expect "git stash clear stash@{4}"
to remove the fourth element in the stash while leaving other
elements intact, we should not blindly throw away everything.

This may change when we start using "git reflog delete" to
selectively nuke a single (or multiple, for that matter) stash
entries when such a command is given.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

JM Ibanez <jm@orangeandbronze.com> writes:

> Jeff King <peff@peff.net> writes:
> ...
>> There was some discussion of a sensible name, but I don't recall seeing
>> a resolution on this: why not "clear stash@{0}" to clear one, and
>> "clear" to clear all? Otherwise, I foresee "git stash clear stash@{0}"
>> followed by "oops, I just deleted all of my stashes."
>
> I actually got hit by this. I didn't know that stash clear affected all
> stashes and lost quite a bit of work that way (I use stash to store
> various test database configs for a tree I work with, and so lost all of
> them when trying to remove one particular stash).

I think something along this line may be necessary to
futureproof our users. 

 git-stash.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index 06cb177..80036ef 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -20,6 +20,10 @@ no_changes () {
 }
 
 clear_stash () {
+	if test $# != 0
+	then
+		die "git stash clear with parameters unimplemented $@"
+	fi
 	if current=$(git rev-parse --verify $ref_stash 2>/dev/null)
 	then
 		git update-ref -d $ref_stash $current
@@ -216,7 +220,7 @@ apply)
 	apply_stash "$@"
 	;;
 clear)
-	clear_stash
+	clear_stash "$@"
 	;;
 create)
 	if test $# -gt 0 && test "$1" = create

  reply	other threads:[~2008-01-05  9:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1199495198-26270-1-git-send-email-casey@nrlssc.navy.mil>
2008-01-05  1:31 ` [PATCH] git-stash: add new 'drop' subcommand Brandon Casey
2008-01-05  1:47   ` Junio C Hamano
2008-01-05  5:46     ` Brandon Casey
2008-01-05  3:51   ` Jeff King
2008-01-05  9:26     ` JM Ibanez
2008-01-05  9:35       ` Junio C Hamano [this message]
2008-01-05 10:00         ` [PATCH] git-stash clear: refuse to work with extra parameter for now Jeff King
2008-01-05 12:36   ` [PATCH] git-stash: add new 'drop' subcommand Marco Costalba

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=7vy7b4bon9.fsf_-_@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=casey@nrlssc.navy.mil \
    --cc=git@vger.kernel.org \
    --cc=jm@orangeandbronze.com \
    --cc=peff@peff.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).