{"thread":{"id":"4704","subject":"xdiff: generate \"anti-diffs\" aka what is common to two files","startedAt":"2006-06-29T04:57:12Z","lastAt":"2006-06-29T18:18:01Z","messageCount":3,"participants":["Linus Torvalds","Junio C Hamano","Davide Libenzi"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"22772","messageId":"Pine.LNX.4.64.0606282149060.12404@g5.osdl.org","threadId":"4704","inReplyTo":null,"subject":"xdiff: generate \"anti-diffs\" aka what is common to two files","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-06-29T04:57:12Z","receivedAt":"2006-06-29T04:57:12Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThis fairly trivial patch adds a new XDL_EMIT_xxx flag to tell libxdiff \nthat we don't want to generate the _diff_ between two files, we want to \nsee the lines that are _common_ to two files.\n\nSo when you set XDL_EMIT_COMMON, xdl_diff() will do everything exactly \nlike it used to do, but the output records it generates just contain the \nlines that aren't part of the diff.\n\nThis is for doing things like generating the common base case for a file \nthat was added in both branches.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\n\nDavide, I say it's a \"fairly trivial patch\", but quite frankly, I'm \nwinging it. I'm not that comfortable with the libxdiff internal workings, \nso while this seems to work for me and make sense, can you please take a \nquick look.\n\nJunio: the patch that actually _uses_ this comes next. It's based on my \nprevious \"throw-away\" example patches, if you want me to base it on \nsomething else, please holler.\n\ndiff --git a/xdiff/xdiff.h b/xdiff/xdiff.h\nindex 2ce10b4..c9f8178 100644\n--- a/xdiff/xdiff.h\n+++ b/xdiff/xdiff.h\n@@ -39,6 +39,7 @@ #define XDL_PATCH_MODEMASK ((1 << 8) - 1\n #define XDL_PATCH_IGNOREBSPACE (1 << 8)\n \n #define XDL_EMIT_FUNCNAMES (1 << 0)\n+#define XDL_EMIT_COMMON (1 << 1)\n \n #define XDL_MMB_READONLY (1 << 0)\n \ndiff --git a/xdiff/xemit.c b/xdiff/xemit.c\nindex ad5bfb1..3604ca1 100644\n--- a/xdiff/xemit.c\n+++ b/xdiff/xemit.c\n@@ -100,6 +100,21 @@ static void xdl_find_func(xdfile_t *xf, \n }\n \n \n+int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,\n+\t\t    xdemitconf_t const *xecfg) {\n+\txdfile_t *xdf = &xe->xdf1;\n+\tconst char *rchg = xdf->rchg;\n+\tlong ix;\n+\n+\tfor (ix = 0; ix < xdf->nrec; ix++) {\n+\t\tif (rchg[ix])\n+\t\t\tcontinue;\n+\t\tif (xdl_emit_record(xdf, ix, \"\", ecb))\n+\t\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\t\t\n+\n int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,\n \t\t  xdemitconf_t const *xecfg) {\n \tlong s1, s2, e1, e2, lctx;\n@@ -107,6 +122,9 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange\n \tchar funcbuf[40];\n \tlong funclen = 0;\n \n+\tif (xecfg->flags & XDL_EMIT_COMMON)\n+\t\treturn xdl_emit_common(xe, xscr, ecb, xecfg);\n+\n \tfor (xch = xche = xscr; xch; xch = xche->next) {\n \t\txche = xdl_get_hunk(xch, xecfg);\n \n"},{"id":"22774","messageId":"7vbqscwl8b.fsf@assigned-by-dhcp.cox.net","threadId":"4704","inReplyTo":"Pine.LNX.4.64.0606282149060.12404@g5.osdl.org","subject":"Re: xdiff: generate \"anti-diffs\" aka what is common to two files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-29T06:04:52Z","receivedAt":"2006-06-29T06:04:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Junio: the patch that actually _uses_ this comes next. It's based on my \n> previous \"throw-away\" example patches, if you want me to base it on \n> something else, please holler.\n\nNah, I appreciate that you did it this way, because it gave me a\ntest case to \"git-am\" your two patches into a temporary branch\nand \"pull --squash\" that into lt/merge-tree branch ;-).\n\n\tgit am ./+LT.mbox\n        ... two patches, applied with --whitespace=strip ...\n\tgit tag -f CG\n        git reset --hard HEAD^^\n        git pull --squash . tag CG\n        git commig -C CG\n        git tag -d CG\n"},{"id":"22811","messageId":"Pine.LNX.4.64.0606291117030.8615@alien.or.mcafeemobile.com","threadId":"4704","inReplyTo":"Pine.LNX.4.64.0606282149060.12404@g5.osdl.org","subject":"Re: xdiff: generate \"anti-diffs\" aka what is common to two files","fromName":"Davide Libenzi","fromEmail":"davidel@xmailserver.org","sentAt":"2006-06-29T18:18:01Z","receivedAt":"2006-06-29T18:18:01Z","isPatch":false,"sender":{"key":"davidel@xmailserver.org","avatar":null},"body":"On Wed, 28 Jun 2006, Linus Torvalds wrote:\n\n> Davide, I say it's a \"fairly trivial patch\", but quite frankly, I'm\n> winging it. I'm not that comfortable with the libxdiff internal workings,\n> so while this seems to work for me and make sense, can you please take a\n> quick look.\n\nLooks fine to me.\n\n\n\n- Davide\n"}]}