Code

Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
[git.git] / git-stash.sh
index 04af892531b400716aad3502a37c89e36c9bad51..1c8b7f92591f87b2d32b51cca6173921c5e041b2 100755 (executable)
@@ -21,7 +21,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 +92,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 +150,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 +173,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"