{"thread":{"id":"57569","subject":"understand Diff Formatting --cc flag?","startedAt":"2022-03-16T11:34:52Z","lastAt":"2022-03-16T19:39:11Z","messageCount":5,"participants":["Andy Zhang","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"451466","messageId":"CAJcwCMMMm=ZnkV3Xxbf+CpJqhRGx1KrdUzh90W-9dEPJ+i40xg@mail.gmail.com","threadId":"57569","inReplyTo":null,"subject":"understand Diff Formatting --cc flag?","fromName":"Andy Zhang","fromEmail":"zhgdrx@gmail.com","sentAt":"2022-03-16T11:36:25Z","receivedAt":"2022-03-16T11:34:52Z","isPatch":false,"sender":{"key":"zhgdrx@gmail.com","avatar":null},"body":"understand Diff Formatting --cc flag?\n\nhi,\n\n  It is really too hard to understand Diff Formatting --cc flag.\n\n  It is hard to understand\"...hunks whose contents in the parents have\nonly two variants..\".\n\n  My question is:\n   1)what does \"variant\" mean here?\n   2)what about all the other cases? 0 variants, 1 variants, and 3\nvariants and even more?\n\n   3)Can I understand \"--cc\" as simply as: \"--cc lists only hunks\nwhich were modified from all parents.\"\n\n\n  Any comments, hinits are welcome!  Thank you in advance!\n\n\n//---------------------------------------------------------------------\nHere is the help from the command: git help log\n\n   Diff Formatting\n       Listed below are options that control the formatting of diff\noutput. Some of them are specific to git-rev-list(1), however other\ndiff options may be given. See git-diff-files(1) for more options.\n\n       -c\n           With this option, diff output for a merge commit shows the\ndifferences from each of the parents to the merge result\nsimultaneously instead of showing pairwise diff between a parent and\nthe\n           result one at a time. Furthermore, it lists only files\nwhich were modified from all parents.\n\n       --cc\n           This flag implies the -c option and further compresses the\npatch output by omitting uninteresting hunks whose contents in the\nparents have only two variants and the merge result picks one of\n           them without modification.\n\n       -m\n           This flag makes the merge commits show the full diff like\nregular commits; for each merge parent, a separate log entry and diff\nis generated. An exception is that only diff against the first\n           parent is shown when --first-parent option is given; in\nthat case, the output represents the changes the merge brought into\nthe then-current branch.\n"},{"id":"451479","messageId":"xmqq8rt9opd1.fsf@gitster.g","threadId":"57569","inReplyTo":"CAJcwCMMMm=ZnkV3Xxbf+CpJqhRGx1KrdUzh90W-9dEPJ+i40xg@mail.gmail.com","subject":"Re: understand Diff Formatting --cc flag?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-16T16:04:42Z","receivedAt":"2022-03-16T16:04:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Zhang <zhgdrx@gmail.com> writes:\n\n> understand Diff Formatting --cc flag?\n>\n> hi,\n>\n>   It is really too hard to understand Diff Formatting --cc flag.\n>\n>   It is hard to understand\"...hunks whose contents in the parents have\n> only two variants..\".\n>\n>   My question is:\n>    1)what does \"variant\" mean here?\n\nYou may be comparing a merge of 5 parents into 1 child.  There are 5\npairwise comparison (parent#1 with the child, parent#2 with the\nchild, ..., parent#5 with the child).\n\nAmong 5 parents, perhaps parent#1 and parent#2 had the same contents,\nand parent#4 and parent#5 had the same contents, different from what\nparent#1 and parent#3 had.  You have 3 variants (parent#1's, #3's\nand #4's; parent#2 has the same contents as #1, parent#5 has the\nsame contents as #4).\n\n>    2)what about all the other cases? 0 variants, 1 variants, and 3\n> variants and even more?\n\nBy definition, you wouldn't be making any comparison if there are 0\nvariants.  1 variant means all the parents are identical, so\nwhichever parent you are interested in, the difference to the child\nis interesting---such a change can only come from the person who\nmerged adding a change that no parent wanted to have.  If many\nparents are different then showing the comparison with the final\nresolution from them is useful.  The case that is not so interesting\nis when one set of parents had something (call it A), and the other\nset of parents had something else (B), and the result is A.  There is\nno interesting merge conflict in there.\n\n"},{"id":"451502","messageId":"CAJcwCMOQnMqqMdR=ZJ-ZgLuZ0wwt9oNxAmXfn4_xpY73rwqFVQ@mail.gmail.com","threadId":"57569","inReplyTo":"xmqq8rt9opd1.fsf@gitster.g","subject":"Re: understand Diff Formatting --cc flag?","fromName":"Andy Zhang","fromEmail":"zhgdrx@gmail.com","sentAt":"2022-03-16T18:57:12Z","receivedAt":"2022-03-16T18:57:25Z","isPatch":false,"sender":{"key":"zhgdrx@gmail.com","avatar":null},"body":"On Thu, Mar 17, 2022 at 12:04 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Andy Zhang <zhgdrx@gmail.com> writes:\n>\n> > understand Diff Formatting --cc flag?\n> >\n> > hi,\n> >\n> >   It is really too hard to understand Diff Formatting --cc flag.\n> >\n> >   It is hard to understand\"...hunks whose contents in the parents have\n> > only two variants..\".\n> >\n> >   My question is:\n> >    1)what does \"variant\" mean here?\n>\n> You may be comparing a merge of 5 parents into 1 child.  There are 5\n> pairwise comparison (parent#1 with the child, parent#2 with the\n> child, ..., parent#5 with the child).\n>\n> Among 5 parents, perhaps parent#1 and parent#2 had the same contents,\n> and parent#4 and parent#5 had the same contents, different from what\n> parent#1 and parent#3 had.  You have 3 variants (parent#1's, #3's\n> and #4's; parent#2 has the same contents as #1, parent#5 has the\n> same contents as #4).\n>\n\n[Andy wrote:] as per your comments, The 3 variants are indeed into the\nfollowing 3 groups.\nMy question is: why can #1 appear inside multiple groups? A and B.\n   <group-A> parent#1, #3, #4;\n   <group-B> parent#2, #1;\n   <group-C> parent#5, #4;\n\n\n\n>\n> >    2)what about all the other cases? 0 variants, 1 variants, and 3\n> > variants and even more?\n>\n> By definition, you wouldn't be making any comparison if there are 0\n> variants.  1 variant means all the parents are identical, so\n> whichever parent you are interested in, the difference to the child\n> is interesting---such a change can only come from the person who\n> merged adding a change that no parent wanted to have.  If many\n> parents are different then showing the comparison with the final\n> resolution from them is useful.  The case that is not so interesting\n> is when one set of parents had something (call it A), and the other\n> set of parents had something else (B), and the result is A.  There is\n> no interesting merge conflict in there.\n>\n\n[Andy wrote:] can I explain  \"--cc\" flag as:\n\"--cc lists only either hunks which were modified from all parents, or\nhunks which were modified from at least two parents and they had\ndifferent variants\"\n"},{"id":"451503","messageId":"CAJcwCMN67UMjSNqf2wbb5ZhK1QGicn7+ihneOc1XxJsdDVtvTw@mail.gmail.com","threadId":"57569","inReplyTo":"xmqq8rt9opd1.fsf@gitster.g","subject":"Re: understand Diff Formatting --cc flag?","fromName":"Andy Zhang","fromEmail":"zhgdrx@gmail.com","sentAt":"2022-03-16T19:00:26Z","receivedAt":"2022-03-16T19:00:39Z","isPatch":false,"sender":{"key":"zhgdrx@gmail.com","avatar":null},"body":"On Thu, Mar 17, 2022 at 12:04 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Andy Zhang <zhgdrx@gmail.com> writes:\n>\n> > understand Diff Formatting --cc flag?\n> >\n> > hi,\n> >\n> >   It is really too hard to understand Diff Formatting --cc flag.\n> >\n> >   It is hard to understand\"...hunks whose contents in the parents have\n> > only two variants..\".\n> >\n> >   My question is:\n> >    1)what does \"variant\" mean here?\n>\n> You may be comparing a merge of 5 parents into 1 child.  There are 5\n> pairwise comparison (parent#1 with the child, parent#2 with the\n> child, ..., parent#5 with the child).\n>\n> Among 5 parents, perhaps parent#1 and parent#2 had the same contents,\n> and parent#4 and parent#5 had the same contents, different from what\n> parent#1 and parent#3 had.  You have 3 variants (parent#1's, #3's\n> and #4's; parent#2 has the same contents as #1, parent#5 has the\n> same contents as #4).\n>\n\n[Andy wrote:] as per your comments, The 3 variants are indeed into the\nfollowing 3 groups.\nMy question is: why can #1 appear inside multiple groups? A and B.\n   <group-A> parent#1, #3, #4;\n   <group-B> parent#2, #1;\n   <group-C> parent#5, #4;\n\n\n> >    2)what about all the other cases? 0 variants, 1 variants, and 3\n> > variants and even more?\n>\n> By definition, you wouldn't be making any comparison if there are 0\n> variants.  1 variant means all the parents are identical, so\n> whichever parent you are interested in, the difference to the child\n> is interesting---such a change can only come from the person who\n> merged adding a change that no parent wanted to have.  If many\n> parents are different then showing the comparison with the final\n> resolution from them is useful.  The case that is not so interesting\n> is when one set of parents had something (call it A), and the other\n> set of parents had something else (B), and the result is A.  There is\n> no interesting merge conflict in there.\n>\n\n[Andy wrote:] can I explain  \"--cc\" flag as:\n\"--cc lists only either hunks which were modified from all parents, or\nhunks which were modified from at least two parents and they had\ndifferent variants\"\n"},{"id":"451504","messageId":"xmqqk0ctlmaw.fsf@gitster.g","threadId":"57569","inReplyTo":"CAJcwCMN67UMjSNqf2wbb5ZhK1QGicn7+ihneOc1XxJsdDVtvTw@mail.gmail.com","subject":"Re: understand Diff Formatting --cc flag?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-16T19:39:03Z","receivedAt":"2022-03-16T19:39:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Zhang <zhgdrx@gmail.com> writes:\n\n>> Among 5 parents, perhaps parent#1 and parent#2 had the same contents,\n>> and parent#4 and parent#5 had the same contents, different from what\n>> parent#1 and parent#3 had.  You have 3 variants (parent#1's, #3's\n>> and #4's; parent#2 has the same contents as #1, parent#5 has the\n>> same contents as #4).\n>>\n>\n> [Andy wrote:] as per your comments, The 3 variants are indeed into the\n> following 3 groups.\n> My question is: why can #1 appear inside multiple groups? A and B.\n>    <group-A> parent#1, #3, #4;\n>    <group-B> parent#2, #1;\n>    <group-C> parent#5, #4;\n\nThe three variants in my sample scenario were (A) used by #1, (B)\nused by #3, and (C) used by #4.  #2 uses (A) and #5 uses (C).\n\nThe contents of #1 does appear twice, in #1 itself and also in #2.\nThat is what \"#2 has the same contents as #1\" means.\n\n> [Andy wrote:] can I explain  \"--cc\" flag as:\n> \"--cc lists only either hunks which were modified from all parents, or\n> hunks which were modified from at least two parents and they had\n> different variants\"\n\nI do not have time to see if that matches the official explanation\nfound in \"git diff --help\", which I just re-read and I think it\ngives the right definition.\n"}]}