From 5a7d454bf657fdf4d726f2319bf554ffd4486ed3 Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 4 Jun 2018 12:56:08 -0400 Subject: Fix stash save bug with fast path index check If the index contains stat data for a modified file, and the file is not racily dirty, and there exists an untracked working tree directory alphabetically after that file, and there are no other changes to the repo, then git_stash_save would fail. It would confuse the untracked working tree directory for the modified file, because they have the same sha: zero. The wt directory has a sha of zero because it's a directory, and the file would have a zero sha because we wouldn't read the file -- we would just know that it doesn't match the index. To fix this confusion, we simply check mode as well as SHA. --- src/diff_generate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/diff_generate.c b/src/diff_generate.c index e11cbe4e4..0105c1701 100644 --- a/src/diff_generate.c +++ b/src/diff_generate.c @@ -273,7 +273,8 @@ static git_diff_delta *diff_delta__last_for_item( break; case GIT_DELTA_MODIFIED: if (git_oid__cmp(&delta->old_file.id, &item->id) == 0 || - git_oid__cmp(&delta->new_file.id, &item->id) == 0) + (delta->new_file.mode == item->mode && + git_oid__cmp(&delta->new_file.id, &item->id) == 0)) return delta; break; default: -- cgit v1.2.1