stash: don't delete untracked files that match pathspec
[gitweb.git] / git-stash.sh
index 8b2ce9afdab6d67e8b9af5fc97a30dc6941323f2..b48b16474865bb9540c0fa108299d77b2f00ecbb 100755 (executable)
@@ -315,10 +315,9 @@ push_stash () {
 
                if test $# != 0
                then
-                       git reset -q -- "$@"
-                       git ls-files -z --modified -- "$@" |
+                       git add -u -- "$@" |
                        git checkout-index -z --force --stdin
-                       git clean --force -q -d -- "$@"
+                       git diff-index -p --cached --binary HEAD -- "$@" | git apply --index -R
                else
                        git reset --hard -q
                fi