1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-18 03:06:17 +02:00

Merge branch 'tg/stash-with-pathspec-fix' into maint

"git stash -- <pathspec>" incorrectly blew away untracked files in
the directory that matched the pathspec, which has been corrected.

* tg/stash-with-pathspec-fix:
  stash: don't delete untracked files that match pathspec
This commit is contained in:
Junio C Hamano 2018-02-15 15:18:13 -08:00
commit 984c8337de
2 changed files with 34 additions and 3 deletions

View File

@ -322,10 +322,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

View File

@ -1064,4 +1064,36 @@ test_expect_success 'stash -k -- <pathspec> leaves unstaged files intact' '
test foo,bar = $(cat foo),$(cat bar)
'
test_expect_success 'stash -- <subdir> leaves untracked files in subdir intact' '
git reset &&
>subdir/untracked &&
>subdir/tracked1 &&
>subdir/tracked2 &&
git add subdir/tracked* &&
git stash -- subdir/ &&
test_path_is_missing subdir/tracked1 &&
test_path_is_missing subdir/tracked2 &&
test_path_is_file subdir/untracked &&
git stash pop &&
test_path_is_file subdir/tracked1 &&
test_path_is_file subdir/tracked2 &&
test_path_is_file subdir/untracked
'
test_expect_success 'stash -- <subdir> works with binary files' '
git reset &&
>subdir/untracked &&
>subdir/tracked &&
cp "$TEST_DIRECTORY"/test-binary-1.png subdir/tracked-binary &&
git add subdir/tracked* &&
git stash -- subdir/ &&
test_path_is_missing subdir/tracked &&
test_path_is_missing subdir/tracked-binary &&
test_path_is_file subdir/untracked &&
git stash pop &&
test_path_is_file subdir/tracked &&
test_path_is_file subdir/tracked-binary &&
test_path_is_file subdir/untracked
'
test_done