diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-13 15:15:27 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-13 15:15:27 -0700 |
commit | 15fc1c02fce2ee6a8a3f625bf24dd782fd905904 (patch) | |
tree | 51f5ba1e438f17516615e06ff031103660918541 /git-stash.sh | |
parent | e636799b4d6a6a8abad151697eae27044bb8e95b (diff) | |
parent | caf1899699b2255111a3db335553e31f3718c1c9 (diff) | |
download | git-15fc1c02fce2ee6a8a3f625bf24dd782fd905904.tar.gz |
Merge branch 'sg/stash-k-i'
* sg/stash-k-i:
Documentation: tweak use case in "git stash save --keep-index"
stash: introduce 'stash save --keep-index' option
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-x | git-stash.sh | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/git-stash.sh b/git-stash.sh index 4938ade589..92531a2951 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -86,6 +86,13 @@ create_stash () { } save_stash () { + keep_index= + case "$1" in + --keep-index) + keep_index=t + shift + esac + stash_msg="$1" if no_changes @@ -104,6 +111,13 @@ save_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" + + git reset --hard + + if test -n "$keep_index" && test -n $i_tree + then + git read-tree --reset -u $i_tree + fi } have_stash () { @@ -153,7 +167,8 @@ apply_stash () { die "$*: no valid stashed state found" unstashed_index_tree= - if test -n "$unstash_index" && test "$b_tree" != "$i_tree" + if test -n "$unstash_index" && test "$b_tree" != "$i_tree" && + test "$c_tree" != "$i_tree" then git diff-tree --binary $s^2^..$s^2 | git apply --cached test $? -ne 0 && @@ -235,7 +250,7 @@ show) ;; save) shift - save_stash "$*" && git-reset --hard + save_stash "$*" ;; apply) shift @@ -268,8 +283,7 @@ pop) if test $# -eq 0 then save_stash && - echo '(To restore them type "git stash apply")' && - git-reset --hard + echo '(To restore them type "git stash apply")' else usage fi |