]> Pileus Git - ~andy/git/blobdiff - git-stash.sh
Merge branch 'maint'
[~andy/git] / git-stash.sh
index 04af892531b400716aad3502a37c89e36c9bad51..534eb168abf8b0b8ae5c2195bf85b66d9cb6b21e 100755 (executable)
@@ -4,6 +4,7 @@
 USAGE='[ | list | show | apply | clear]'
 
 SUBDIRECTORY_OK=Yes
+OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
 cd_to_toplevel
@@ -21,7 +22,7 @@ no_changes () {
 clear_stash () {
        if current=$(git rev-parse --verify $ref_stash 2>/dev/null)
        then
-               git update-ref -d refs/stash $current
+               git update-ref -d $ref_stash $current
        fi
 }
 
@@ -92,6 +93,10 @@ save_stash () {
                clear_stash || die "Cannot initialize stash"
 
        create_stash "$stash_msg"
+
+       # Make sure the reflog for stash is kept.
+       : >>"$GIT_DIR/logs/$ref_stash"
+
        git update-ref -m "$stash_msg" $ref_stash $w_commit ||
                die "Cannot save the current status"
        printf >&2 'Saved "%s"\n' "$stash_msg"
@@ -146,7 +151,7 @@ apply_stash () {
        unstashed_index_tree=
        if test -n "$unstash_index" && test "$b_tree" != "$i_tree"
        then
-               git diff --binary $s^2^..$s^2 | git apply --cached
+               git diff-tree --binary $s^2^..$s^2 | git apply --cached
                test $? -ne 0 &&
                        die 'Conflicts in index. Try without --index.'
                unstashed_index_tree=$(git-write-tree) ||
@@ -169,7 +174,7 @@ apply_stash () {
                        git read-tree "$unstashed_index_tree"
                else
                        a="$TMP-added" &&
-                       git diff --cached --name-only --diff-filter=A $c_tree >"$a" &&
+                       git diff-index --cached --name-only --diff-filter=A $c_tree >"$a" &&
                        git read-tree --reset $c_tree &&
                        git update-index --add --stdin <"$a" ||
                                die "Cannot unstage modified files"