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

[PATCH] git-stash clear: refuse to work with extra parameter for now

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2008, 09:35 UTC
Message-ID
<7vy7b4bon9.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<871w8woc77.fsf@adler.orangeandbronze.com>

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:
Show 11 quoted lines
> 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
Previous: JM IbanezNext: Jeff King
Message 6 of 8 in “git-stash: add new 'drop' subcommand”
  1. git-stash: add new 'drop' subcommandBrandon Casey, Jan 5, 2008
  2. Junio C HamanoJan 5, 2008
  3. Brandon CaseyJan 5, 2008
  4. Jeff KingJan 5, 2008
  5. JM IbanezJan 5, 2008
  6. git-stash clear: refuse to work with extra parameter for nowJunio C Hamano, Jan 5, 2008
  7. Jeff KingJan 5, 2008
  8. Marco CostalbaJan 5, 2008

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.