Thread (1 message) 1 message, 1 author, 2016-06-15

Re* BUG?: git diff with 3 args consults work tree when it shouldn't

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:44
Subsystem: the rest · Maintainer: Linus Torvalds

What happens is that the more-than-two-ways combined diff is sometimes
used to show the difference _to_ the working tree files.

In combine-diff.c::show_patch_diff(), we try to detect that case by
checking if sha1 recorded as "the result" is null, because diff-files will
give us 0{40} as the blob object name for files in the working tree.

Unfortunately, that forgets another case where blob object is null, which
is when the merge result tree _deleted_ the path.

This patch is not tested outside your test case. IOW, I know it will get
three-tree case correctly, but I didn't test it with cases where we should
look at the working tree files, so this may introduce regressions.

See 713a11f (combine-diff: diff-files fix., 2006-02-13) if you are
interested. I suspect that we may need to add a bit to the API to tell
this function if the end result is in the working tree.

 combine-diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/combine-diff.c b/combine-diff.c
index be67cfc..b4f1050 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -777,7 +777,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 	struct sline *sline; /* survived lines */
 	int mode_differs = 0;
 	int i, show_hunks;
-	int working_tree_file = is_null_sha1(elem->sha1);
+	int working_tree_file = is_null_sha1(elem->sha1) && elem->mode;
 	mmfile_t result_file;
 	struct userdiff_driver *userdiff;
 	struct userdiff_driver *textconv = NULL;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help