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

[PATCH] stash clear: allow -v/--verbose to be passed

From
Alexander Kuleshov <kuleshovmail@gmail.com>
Date
Jan 13, 2015, 17:54 UTC
Message-ID
<1421171677-12215-1-git-send-email-kuleshovmail@gmail.com>
Added new option -v/--verbose to 'git stash clear' for verbose output.
For example:
    $ git stash clear -v
    Removed stash@{0}: WIP on stash-clear-verbose: 0ae1f56 Merge branch 'bp/diff-relative-config' into pu
    Removed stash@{1}: WIP on stash-clear-verbose: 0ae1f56 Merge branch 'bp/diff-relative-config' into pu
    Removed stash@{2}: WIP on stash-clear-verbose: 0ae1f56 Merge branch 'bp/diff-relative-config' into pu
    Removed stash@{3}: WIP on master: addfb21 Git 2.3.0-rc0
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 Documentation/git-stash.txt |  4 ++--
 git-stash.sh                | 15 ++++++++++-----
 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 375213f..f5b3dd8 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -15,7 +15,7 @@ SYNOPSIS
 'git stash' branch <branchname> [<stash>]
 'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
 	     [-u|--include-untracked] [-a|--all] [<message>]]
-'git stash' clear
+'git stash' clear [-v|--verbose]
 'git stash' create [<message>]
 'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
 
@@ -136,7 +136,7 @@ the stash is applied on top of the commit that was HEAD at the time
 `git stash` was run, it restores the originally stashed state with
 no conflicts.
 
-clear::
+clear [-v|--verbose]::
 	Remove all the stashed states. Note that those states will then
 	be subject to pruning, and may be impossible to recover (see
 	'Examples' below for a possible strategy).
diff --git a/git-stash.sh b/git-stash.sh
index 6846b18..9f16289 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -9,7 +9,7 @@ USAGE="list [<options>]
    or: $dashless branch <branchname> [<stash>]
    or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
 		       [-u|--include-untracked] [-a|--all] [<message>]]
-   or: $dashless clear"
+   or: $dashless clear [-v|--verbose]"
 
 SUBDIRECTORY_OK=Yes
 OPTIONS_SPEC=
@@ -46,12 +46,17 @@ untracked_files () {
 }
 
 clear_stash () {
-	if test $# != 0
-	then
-		die "$(gettext "git stash clear with parameters is unimplemented")"
-	fi
 	if current=$(git rev-parse --verify --quiet $ref_stash)
 	then
+		case "$1" in
+			-v|--verbose)
+			    shift
+			    git log --format="%gd: %gs" -g --first-parent -m "$@" $ref_stash -- | sed -e 's/^/Removed /g'
+			    ;;
+			*)
+			    break
+			    ;;
+		esac
 		git update-ref -d $ref_stash $current
 	fi
 }
-- 
2.3.0.rc0.239.g0ae1f56.dirty
Next: Junio C Hamano
Message 1 of 2 in “stash clear: allow -v/--verbose to be passed”
  1. stash clear: allow -v/--verbose to be passedAlexander Kuleshov, Jan 13, 2015
  2. Junio C HamanoJan 13, 2015

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.