]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-stash.sh
Remove outdated references to cogito in documentation
[git.git] / git-stash.sh
index 873e7be6ad1f1906546f13fb59f624e2f4e37ae2..5bbda47b7b6e286e7e8e5d002d7ed461a831b579 100755 (executable)
@@ -57,7 +57,7 @@ save_stash () {
 
        # state of the index
        i_tree=$(git write-tree) &&
-       i_commit=$(printf 'index on %s' "$msg" |
+       i_commit=$(printf 'index on %s\n' "$msg" |
                git commit-tree $i_tree -p $b_commit) ||
                die "Cannot save the current index state"
 
@@ -139,7 +139,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) ||
@@ -157,15 +157,16 @@ apply_stash () {
        if git-merge-recursive $b_tree -- $c_tree $w_tree
        then
                # No conflict
-               a="$TMP-added" &&
-               git diff --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"
-               rm -f "$a"
                if test -n "$unstashed_index_tree"
                then
                        git read-tree "$unstashed_index_tree"
+               else
+                       a="$TMP-added" &&
+                       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"
+                       rm -f "$a"
                fi
                git status || :
        else