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 <kuleshovm...@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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to