summaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-12-06 20:25:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-12-06 22:16:53 (GMT)
commit9d4e28ead5bf133d014dfc9e9345f6bf083eefea (patch)
treec57aac1e945bec24e9f39b0a223a2a5ac1e5ec00 /git-stash.sh
parent05219a1276341e72d8082d76b7f5ed394b7437a4 (diff)
downloadgit-9d4e28ead5bf133d014dfc9e9345f6bf083eefea.zip
git-9d4e28ead5bf133d014dfc9e9345f6bf083eefea.tar.gz
git-9d4e28ead5bf133d014dfc9e9345f6bf083eefea.tar.bz2
stash: prefer plumbing over git-diff
When creating a stash, we need to look at the diff between the working tree and HEAD, and do so using the git-diff porcelain. Because git-diff enables porcelain config like renames by default, this causes at least one problem. The --name-only format will not mention the source side of a rename, meaning we will fail to stash a deletion that is part of a rename. We could fix that case by passing --no-renames, but this is a symptom of a larger problem. We should be using the diff-index plumbing here, which does not have renames enabled by default, and also does not respect any potentially confusing config options. Reported-by: Matthew Patey <matthew.patey2167@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/git-stash.sh b/git-stash.sh
index c7509e8..0934481 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -116,7 +116,7 @@ create_stash () {
git read-tree --index-output="$TMPindex" -m $i_tree &&
GIT_INDEX_FILE="$TMPindex" &&
export GIT_INDEX_FILE &&
- git diff --name-only -z HEAD -- >"$TMP-stagenames" &&
+ git diff-index --name-only -z HEAD -- >"$TMP-stagenames" &&
git update-index -z --add --remove --stdin <"$TMP-stagenames" &&
git write-tree &&
rm -f "$TMPindex"