summaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-27 14:29:41 -0700
committerJunio C Hamano <gitster@pobox.com>2013-06-27 14:29:41 -0700
commitfa4bf9edb9300da2688da8a920c506376a14de0a (patch)
tree0a2aca289c7dcc2d1f12c57fb1a925c12db46506 /git-stash.sh
parent85318f521f6c0b9843d6da12abf67f2de7608431 (diff)
parent20351bb06bf4d32ef3d1a6849d01636f6593339f (diff)
downloadgit-fa4bf9edb9300da2688da8a920c506376a14de0a.tar.gz
Merge branch 'rr/rebase-stash-store'
Finishing touches for the "git rebase --autostash" feature introduced earlier. * rr/rebase-stash-store: rebase: use 'git stash store' to simplify logic stash: introduce 'git stash store' stash: simplify option parser for create stash doc: document short form -p in synopsis stash doc: add a warning about using create
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh52
1 files changed, 42 insertions, 10 deletions
diff --git a/git-stash.sh b/git-stash.sh
index bbefdf6424..1e541a2125 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -156,6 +156,41 @@ create_stash () {
die "$(gettext "Cannot record working tree state")"
}
+store_stash () {
+ while test $# != 0
+ do
+ case "$1" in
+ -m|--message)
+ shift
+ stash_msg="$1"
+ ;;
+ -q|--quiet)
+ quiet=t
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+ test $# = 1 ||
+ die "$(eval_gettext "\"$dashless store\" requires one <commit> argument")"
+
+ w_commit="$1"
+ if test -z "$stash_msg"
+ then
+ stash_msg="Created via \"git stash store\"."
+ fi
+
+ # Make sure the reflog for stash is kept.
+ : >>"$GIT_DIR/logs/$ref_stash"
+ git update-ref -m "$stash_msg" $ref_stash $w_commit
+ ret=$?
+ test $ret != 0 && test -z $quiet &&
+ die "$(eval_gettext "Cannot update \$ref_stash with \$w_commit")"
+ return $ret
+}
+
save_stash () {
keep_index=
patch_mode=
@@ -227,12 +262,8 @@ save_stash () {
clear_stash || die "$(gettext "Cannot initialize stash")"
create_stash "$stash_msg" $untracked
-
- # Make sure the reflog for stash is kept.
- : >>"$GIT_DIR/logs/$ref_stash"
-
- git update-ref -m "$stash_msg" $ref_stash $w_commit ||
- die "$(gettext "Cannot save the current status")"
+ store_stash -m "$stash_msg" -q $w_commit ||
+ die "$(gettext "Cannot save the current status")"
say Saved working directory and index state "$stash_msg"
if test -z "$patch_mode"
@@ -546,12 +577,13 @@ clear)
clear_stash "$@"
;;
create)
- if test $# -gt 0 && test "$1" = create
- then
- shift
- fi
+ shift
create_stash "$*" && echo "$w_commit"
;;
+store)
+ shift
+ store_stash "$@"
+ ;;
drop)
shift
drop_stash "$@"