diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-06-27 14:29:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-06-27 14:29:41 -0700 |
commit | fa4bf9edb9300da2688da8a920c506376a14de0a (patch) | |
tree | 0a2aca289c7dcc2d1f12c57fb1a925c12db46506 /git-stash.sh | |
parent | Update draft release notes to 1.8.4 (diff) | |
parent | rebase: use 'git stash store' to simplify logic (diff) | |
download | tgif-fa4bf9edb9300da2688da8a920c506376a14de0a.tar.xz |
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-x | git-stash.sh | 52 |
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 "$@" |