git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-diff-tree -B broken

From
Junio C Hamano <junkio@cox.net>
Date
Apr 9, 2006, 02:51 UTC
Message-ID
<7vwtdzcvhb.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060409004605.GU27689@pasky.or.cz>
Petr Baudis <pasky@ucw.cz> writes:
Show 12 quoted lines
> 	$ git-diff-tree -r -p -B -M 916d8240bfc8ef5b80780b1a32ebb83ed055a178 \
> 		3c9324ea16c345fc0bc0f11041905ba714797e4a cg-mkpatch
> 	diff --git a/cg-mkpatch b/cg-mkpatch
> 	dissimilarity index 57%
> 	index 74fe917..c932bc9 100755
> 	--- cg-mkpatch
> 	+++ cg-mkpatch
> 	@@ -0,0 +0,0 @@
>
> and nothing else. I'm too tired to debug or bisect this (xdiff
> introduction is the obvious suspect, I guess), just didn't want this
> to slip into the looming 1.3.0 so reporting early.
Thanks.

There are two issues. One of them is addressed with the attached patch, which is just an artifact of the xdiff introduction.

Another issue is a bit bigger.

The changes to the sample cg-mkpatch is estimated to be big enough to get broken, just in case if there is another file whose postimage that is more similar than the postimage of cg-mkpatch itself, so that it can be matched up with the other file, but it is _not_ dissimilar enough that diffcore_break() code marks it to be merged back together if pieces of the broken pair do not get matched up with other files. And in this particular case, since you are limiting the search space to a single file, there is no other files to match, so the broken pair should survive the rename detection match-up, and they should be shown as a normal diff without dissimilarity index at all.

The funny thing is, the broken pair are matched up with themselves, with similarity index of 57% (they originally are from the same filepair, so that is natural). So in this case, rename code _should_ take notice. I'll work on a fix.

-- >8 --
diff --git a/diff.c b/diff.c
index ce98a90..e887410 100644
--- a/diff.c
+++ b/diff.c
@@ -145,8 +145,9 @@ static void emit_rewrite_diff(const char
 			      struct diff_filespec *one, 
 			      struct diff_filespec *two)
 {
-	/* Use temp[i].name as input, name_a and name_b as labels */
 	int lc_a, lc_b;
+	diff_populate_filespec(one, 0);
+	diff_populate_filespec(two, 0);
 	lc_a = count_lines(one->data, one->size);
 	lc_b = count_lines(two->data, two->size);
 	printf("--- %s\n+++ %s\n@@ -", name_a, name_b);
Previous: Petr BaudisNext: Junio C Hamano
Message 2 of 3 in “git-diff-tree -B broken”
  1. Petr BaudisApr 9, 2006
  2. Junio C HamanoApr 9, 2006
  3. diffcore-rename: fix merging back a broken pair.Junio C Hamano, Apr 9, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.