stash clear: allow -v/--verbose to be passed
PATCH 1/1 stash clear: allow -v/--verbose to be passed
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--- Documentation/git-stash.txt | 4 ++-- git-stash.sh | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-)
Documentation/git-stash.txt +2 -2
@@ -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).
git-stash.sh +10 -5
@@ -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 }
Signature · 1 line
2.3.0.rc0.239.g0ae1f56.dirty
Quoted 1 line · Alexander Kuleshov
Added new option -v/--verbose to 'git stash clear' for verbose output.
Why?
I would sort-of understand if it were "git stash clear --confirm" that internally runs "git stash list" and then asks "Are you sure (Y/n)?" and then finally clears [*1*], but what value does it add to the system to be able to see what you lost and cannot recover anymore after the damage is done?
Note that I am not advocating adding "clear --confirm" here (that is what I mean by "sort-of understand"); the users can do that "Do I really want to discard these?" themselves.
[Footnote]
*1* Or perhaps copying the stash to boneyard/stash before removing them so that they can "undo" once.