File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -322,10 +322,9 @@ push_stash () {
322
322
323
323
if test $# ! = 0
324
324
then
325
- git reset -q -- " $@ "
326
- git ls-files -z --modified -- " $@ " |
325
+ git add -u -- " $@ " |
327
326
git checkout-index -z --force --stdin
328
- git clean --force -q -d -- " $@ "
327
+ git diff-index -p --cached --binary HEAD -- " $@ " | git apply --index -R
329
328
else
330
329
git reset --hard -q
331
330
fi
Original file line number Diff line number Diff line change @@ -1064,4 +1064,36 @@ test_expect_success 'stash -k -- <pathspec> leaves unstaged files intact' '
1064
1064
test foo,bar = $(cat foo),$(cat bar)
1065
1065
'
1066
1066
1067
+ test_expect_success ' stash -- <subdir> leaves untracked files in subdir intact' '
1068
+ git reset &&
1069
+ >subdir/untracked &&
1070
+ >subdir/tracked1 &&
1071
+ >subdir/tracked2 &&
1072
+ git add subdir/tracked* &&
1073
+ git stash -- subdir/ &&
1074
+ test_path_is_missing subdir/tracked1 &&
1075
+ test_path_is_missing subdir/tracked2 &&
1076
+ test_path_is_file subdir/untracked &&
1077
+ git stash pop &&
1078
+ test_path_is_file subdir/tracked1 &&
1079
+ test_path_is_file subdir/tracked2 &&
1080
+ test_path_is_file subdir/untracked
1081
+ '
1082
+
1083
+ test_expect_success ' stash -- <subdir> works with binary files' '
1084
+ git reset &&
1085
+ >subdir/untracked &&
1086
+ >subdir/tracked &&
1087
+ cp "$TEST_DIRECTORY"/test-binary-1.png subdir/tracked-binary &&
1088
+ git add subdir/tracked* &&
1089
+ git stash -- subdir/ &&
1090
+ test_path_is_missing subdir/tracked &&
1091
+ test_path_is_missing subdir/tracked-binary &&
1092
+ test_path_is_file subdir/untracked &&
1093
+ git stash pop &&
1094
+ test_path_is_file subdir/tracked &&
1095
+ test_path_is_file subdir/tracked-binary &&
1096
+ test_path_is_file subdir/untracked
1097
+ '
1098
+
1067
1099
test_done
You can’t perform that action at this time.
0 commit comments