{"thread":{"id":"5472","subject":"[PATCH] Do 3-way diff between HEAD, index and working directory","startedAt":"2006-09-04T11:38:40Z","lastAt":"2006-09-04T22:23:16Z","messageCount":2,"participants":["Paul Mackerras","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"26300","messageId":"17660.4160.642852.177249@cargo.ozlabs.ibm.com","threadId":"5472","inReplyTo":null,"subject":"[PATCH] Do 3-way diff between HEAD, index and working directory","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-09-04T11:38:40Z","receivedAt":"2006-09-04T11:38:40Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"This implements a 3-way diff between the HEAD commit, the state in the\nindex, and the working directory.  This is like the n-way diff for a\nmerge, and uses much of the same code.  It is invoked with the -c flag\nto git-diff-index, which it already accepted and did nothing with.\n\nSigned-off-by: Paul Mackerras <paulus@samba.org>\n---\nJunio, does this look right?  It seems to work OK, and I need it for\nmy new git commit tool, for the cases where the user has done a\ncheckin and then further modified the working file.  It will be needed\neven more when I implement partial checkins within a file.\n\nThanks,\nPaul.\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 9edfa92..fc69fb9 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -213,6 +213,31 @@ static int show_modified(struct rev_info\n \t\treturn -1;\n \t}\n \n+\tif (revs->combine_merges && !cached &&\n+\t    (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) {\n+\t\tstruct combine_diff_path *p;\n+\t\tint pathlen = ce_namelen(new);\n+\n+\t\tp = xmalloc(combine_diff_path_size(2, pathlen));\n+\t\tp->path = (char *) &p->parent[2];\n+\t\tp->next = NULL;\n+\t\tp->len = pathlen;\n+\t\tmemcpy(p->path, new->name, pathlen);\n+\t\tp->path[pathlen] = 0;\n+\t\tp->mode = ntohl(mode);\n+\t\thashclr(p->sha1);\n+\t\tmemset(p->parent, 0, 2 * sizeof(struct combine_diff_parent));\n+\t\tp->parent[0].status = DIFF_STATUS_MODIFIED;\n+\t\tp->parent[0].mode = ntohl(new->ce_mode);\n+\t\thashcpy(p->parent[0].sha1, new->sha1);\n+\t\tp->parent[1].status = DIFF_STATUS_MODIFIED;\n+\t\tp->parent[1].mode = ntohl(old->ce_mode);\n+\t\thashcpy(p->parent[1].sha1, old->sha1);\n+\t\tshow_combined_diff(p, 2, revs->dense_combined_merges, revs);\n+\t\tfree(p);\n+\t\treturn 0;\n+\t}\n+\n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !hashcmp(sha1, old->sha1) &&\n \t    !revs->diffopt.find_copies_harder)\n\n-- \nVGER BF report: U 0.519891\n"},{"id":"26324","messageId":"7vpsebl19n.fsf@assigned-by-dhcp.cox.net","threadId":"5472","inReplyTo":"17660.4160.642852.177249@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] Do 3-way diff between HEAD, index and working directory","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-04T22:23:16Z","receivedAt":"2006-09-04T22:23:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Mackerras <paulus@samba.org> writes:\n\n> This implements a 3-way diff between the HEAD commit, the state in the\n> index, and the working directory.  This is like the n-way diff for a\n> merge, and uses much of the same code.  It is invoked with the -c flag\n> to git-diff-index, which it already accepted and did nothing with.\n>\n> Signed-off-by: Paul Mackerras <paulus@samba.org>\n> ---\n> Junio, does this look right?\n\nSeems correct from a cursory look.  This also seems to change\nthe behaviour for an unmerged entry case slightly but I think\nit is for the better (depending on the definition of \"better\" --\nsome people may feel combined diff to be weird and confusing).\n"}]}