From 9d4e28ead5bf133d014dfc9e9345f6bf083eefea Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 6 Dec 2016 15:25:21 -0500 Subject: 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 Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-stash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-stash.sh') diff --git a/git-stash.sh b/git-stash.sh index c7509e8da4..0934481913 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" -- cgit v1.2.1