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

Re: [PATCH] git-diff: fix combined diff

From
Junio C Hamano <junkio@cox.net>
Date
Feb 23, 2007, 06:09 UTC
Message-ID
<7v3b4xbe1i.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vbqjlbg8y.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 5 quoted lines
> With this,
>
> 	$ git diff maint master next pu
>
> starts working as planned ;-).

By the way, your commit log message does not seem to say why it is a fix correctly. Here is what I replaced it with.

-- >8 -- cut here -- >8 --
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: Fri, 23 Feb 2007 05:20:32 +0100
Subject: [PATCH] git-diff: fix combined diff

The code forgets that typecast binds tighter than addition, in other words:

    (cast *)array + i  === ((cast *)array) + i
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 builtin-diff.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-diff.c b/builtin-diff.c
index a659020..c387ebb 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -192,7 +192,8 @@ static int builtin_diff_combined(struct rev_info *revs,
 	parent = xmalloc(ents * sizeof(*parent));
 	/* Again, the revs are all reverse */
 	for (i = 0; i < ents; i++)
-		hashcpy((unsigned char*)parent + i, ent[ents - 1 - i].item->sha1);
+		hashcpy((unsigned char *)(parent + i),
+			ent[ents - 1 - i].item->sha1);
 	diff_tree_combined(parent[0], parent + 1, ents - 1,
 			   revs->dense_combined_merges, revs);
 	return 0;
-- 
1.5.0.1.619.g04c5c
Previous: Junio C HamanoNext: Jeff King
Message 3 of 5 in “git-diff: fix combined diff”
  1. git-diff: fix combined diffJohannes Schindelin, Feb 23, 2007
  2. Junio C HamanoFeb 23, 2007
  3. Junio C HamanoFeb 23, 2007
  4. Jeff KingFeb 23, 2007
  5. Johannes SchindelinFeb 23, 2007

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.