Skip to content

Commit db09f21

Browse files
committed
Merge branch 'jk/stash-disable-renames-internally'
When diff.renames configuration is on (and with Git 2.9 and later, it is enabled by default, which made it worse), "git stash" misbehaved if a file is removed and another file with a very similar content is added. * jk/stash-disable-renames-internally: stash: prefer plumbing over git-diff
2 parents da72ee8 + 9d4e28e commit db09f21

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

git-stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ create_stash () {
115115
git read-tree --index-output="$TMPindex" -m $i_tree &&
116116
GIT_INDEX_FILE="$TMPindex" &&
117117
export GIT_INDEX_FILE &&
118-
git diff --name-only -z HEAD -- >"$TMP-stagenames" &&
118+
git diff-index --name-only -z HEAD -- >"$TMP-stagenames" &&
119119
git update-index -z --add --remove --stdin <"$TMP-stagenames" &&
120120
git write-tree &&
121121
rm -f "$TMPindex"

t/t3903-stash.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,4 +766,13 @@ test_expect_success 'stash list --cc shows combined diff' '
766766
test_cmp expect actual
767767
'
768768

769+
test_expect_success 'stash is not confused by partial renames' '
770+
mv file renamed &&
771+
git add renamed &&
772+
git stash &&
773+
git stash apply &&
774+
test_path_is_file renamed &&
775+
test_path_is_missing file
776+
'
777+
769778
test_done

0 commit comments

Comments
 (0)