summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0e987a1)
raw | patch | inline | side by side (parent: 0e987a1)
author | Stephen Boyd <bebarino@gmail.com> | |
Thu, 18 Jun 2009 01:07:37 +0000 (18:07 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 18 Jun 2009 18:54:57 +0000 (11:54 -0700) |
Teach stash pop, apply, save, and drop to be quiet when told. By using
the quiet option (-q), these actions will be silent unless errors are
encountered.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
the quiet option (-q), these actions will be silent unless errors are
encountered.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-stash.txt | patch | blob | history | |
git-stash.sh | patch | blob | history | |
t/t3903-stash.sh | patch | blob | history |
index a42d4c85bddd539d46aaaafea6bf6412cd7c3436..1c64a02fe576a6bdad2afcbc96391ce0c2d541c4 100644 (file)
--------
[verse]
'git stash' list [<options>]
-'git stash' ( show | drop ) [<stash>]
-'git stash' ( pop | apply ) [--index] [<stash>]
+'git stash' show [<stash>]
+'git stash' drop [-q|--quiet] [<stash>]
+'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
'git stash' branch <branchname> [<stash>]
-'git stash' [save [--keep-index] [<message>]]
+'git stash' [save [--keep-index] [-q|--quiet] [<message>]]
'git stash' clear
'git stash' create
OPTIONS
-------
-save [--keep-index] [<message>]::
+save [--keep-index] [-q|--quiet] [<message>]::
Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them. This is the default action when no
it will accept any format known to 'git-diff' (e.g., `git stash show
-p stash@\{1}` to view the second most recent stash in patch form).
-pop [<stash>]::
+pop [--index] [-q|--quiet] [<stash>]::
Remove a single stashed state from the stash list and apply it
on top of the current working tree state, i.e., do the inverse
+
When no `<stash>` is given, `stash@\{0}` is assumed.
-apply [--index] [<stash>]::
+apply [--index] [-q|--quiet] [<stash>]::
Like `pop`, but do not remove the state from the stash list.
Remove all the stashed states. Note that those states will then
be subject to pruning, and may be difficult or impossible to recover.
-drop [<stash>]::
+drop [-q|--quiet] [<stash>]::
Remove a single stashed state from the stash list. When no `<stash>`
is given, it removes the latest one. i.e. `stash@\{0}`
diff --git a/git-stash.sh b/git-stash.sh
index e6a586720978ec516d243590b0e403ed7ecfe36c..531c7c31aca87db77e54c46ffb89899652a79fcd 100755 (executable)
--- a/git-stash.sh
+++ b/git-stash.sh
dashless=$(basename "$0" | sed -e 's/-/ /')
USAGE="list [<options>]
- or: $dashless ( show | drop ) [<stash>]
- or: $dashless ( pop | apply ) [--index] [<stash>]
+ or: $dashless show [<stash>]
+ or: $dashless drop [-q|--quiet] [<stash>]
+ or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
or: $dashless branch <branchname> [<stash>]
- or: $dashless [save [--keep-index] [<message>]]
+ or: $dashless [save [--keep-index] [-q|--quiet] [<message>]]
or: $dashless clear"
SUBDIRECTORY_OK=Yes
save_stash () {
keep_index=
- case "$1" in
- --keep-index)
- keep_index=t
+ while test $# != 0
+ do
+ case "$1" in
+ --keep-index)
+ keep_index=t
+ ;;
+ -q|--quiet)
+ GIT_QUIET=t
+ ;;
+ *)
+ break
+ ;;
+ esac
shift
- esac
+ done
stash_msg="$*"
git update-index -q --refresh
if no_changes
then
- echo 'No local changes to save'
+ say 'No local changes to save'
exit 0
fi
test -f "$GIT_DIR/logs/$ref_stash" ||
git update-ref -m "$stash_msg" $ref_stash $w_commit ||
die "Cannot save the current status"
- printf 'Saved working directory and index state "%s"\n' "$stash_msg"
+ say Saved working directory and index state "$stash_msg"
- git reset --hard
+ git reset --hard ${GIT_QUIET:+-q}
if test -n "$keep_index" && test -n $i_tree
then
die 'Cannot apply to a dirty working tree, please stage your changes'
unstash_index=
- case "$1" in
- --index)
- unstash_index=t
+
+ while test $# != 0
+ do
+ case "$1" in
+ --index)
+ unstash_index=t
+ ;;
+ -q|--quiet)
+ GIT_QUIET=t
+ ;;
+ *)
+ break
+ ;;
+ esac
shift
- esac
+ done
# current index state
c_tree=$(git write-tree) ||
export GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree
"
+ if test -n "$GIT_QUIET"
+ then
+ export GIT_MERGE_VERBOSITY=0
+ fi
if git-merge-recursive $b_tree -- $c_tree $w_tree
then
# No conflict
die "Cannot unstage modified files"
rm -f "$a"
fi
- git status || :
+ squelch=
+ if test -n "$GIT_QUIET"
+ then
+ squelch='>/dev/null 2>&1'
+ fi
+ eval "git status $squelch" || :
else
# Merge conflict; keep the exit status from merge-recursive
status=$?
drop_stash () {
have_stash || die 'No stash entries to drop'
+ while test $# != 0
+ do
+ case "$1" in
+ -q|--quiet)
+ GIT_QUIET=t
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
if test $# = 0
then
set x "$ref_stash@{0}"
die "$*: not a valid stashed state"
git reflog delete --updateref --rewrite "$@" &&
- echo "Dropped $* ($s)" || die "$*: Could not drop stash entry"
+ say "Dropped $* ($s)" || die "$*: Could not drop stash entry"
# clear_stash if we just dropped the last stash entry
git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
if test $# -eq 0
then
save_stash &&
- echo '(To restore them type "git stash apply")'
+ say '(To restore them type "git stash apply")'
else
usage
fi
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 7484cbede6ccd3ecb56a3ebff734740cb543c0a4..7a3fb679571a9fc79135f8b9495462f723b663af 100755 (executable)
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
test 0 = $(git stash list | wc -l)
'
+test_expect_success 'apply -q is quiet' '
+ echo foo > file &&
+ git stash &&
+ git stash apply -q > output.out 2>&1 &&
+ test ! -s output.out
+'
+
+test_expect_success 'save -q is quiet' '
+ git stash save --quiet > output.out 2>&1 &&
+ test ! -s output.out
+'
+
+test_expect_success 'pop -q is quiet' '
+ git stash pop -q > output.out 2>&1 &&
+ test ! -s output.out
+'
+
+test_expect_success 'drop -q is quiet' '
+ git stash &&
+ git stash drop -q > output.out 2>&1 &&
+ test ! -s output.out
+'
+
test_done