* understand Diff Formatting --cc flag? @ 2022-03-16 11:36 Andy Zhang 2022-03-16 16:04 ` Junio C Hamano 0 siblings, 1 reply; 5+ messages in thread From: Andy Zhang @ 2022-03-16 11:36 UTC (permalink / raw) To: git understand Diff Formatting --cc flag? hi, It is really too hard to understand Diff Formatting --cc flag. It is hard to understand"...hunks whose contents in the parents have only two variants..". My question is: 1)what does "variant" mean here? 2)what about all the other cases? 0 variants, 1 variants, and 3 variants and even more? 3)Can I understand "--cc" as simply as: "--cc lists only hunks which were modified from all parents." Any comments, hinits are welcome! Thank you in advance! //--------------------------------------------------------------------- Here is the help from the command: git help log Diff Formatting Listed below are options that control the formatting of diff output. Some of them are specific to git-rev-list(1), however other diff options may be given. See git-diff-files(1) for more options. -c With this option, diff output for a merge commit shows the differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time. Furthermore, it lists only files which were modified from all parents. --cc This flag implies the -c option and further compresses the patch output by omitting uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification. -m This flag makes the merge commits show the full diff like regular commits; for each merge parent, a separate log entry and diff is generated. An exception is that only diff against the first parent is shown when --first-parent option is given; in that case, the output represents the changes the merge brought into the then-current branch. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: understand Diff Formatting --cc flag? 2022-03-16 11:36 understand Diff Formatting --cc flag? Andy Zhang @ 2022-03-16 16:04 ` Junio C Hamano 2022-03-16 18:57 ` Andy Zhang 2022-03-16 19:00 ` Andy Zhang 0 siblings, 2 replies; 5+ messages in thread From: Junio C Hamano @ 2022-03-16 16:04 UTC (permalink / raw) To: Andy Zhang; +Cc: git Andy Zhang <zhgdrx@gmail.com> writes: > understand Diff Formatting --cc flag? > > hi, > > It is really too hard to understand Diff Formatting --cc flag. > > It is hard to understand"...hunks whose contents in the parents have > only two variants..". > > My question is: > 1)what does "variant" mean here? You may be comparing a merge of 5 parents into 1 child. There are 5 pairwise comparison (parent#1 with the child, parent#2 with the child, ..., parent#5 with the child). Among 5 parents, perhaps parent#1 and parent#2 had the same contents, and parent#4 and parent#5 had the same contents, different from what parent#1 and parent#3 had. You have 3 variants (parent#1's, #3's and #4's; parent#2 has the same contents as #1, parent#5 has the same contents as #4). > 2)what about all the other cases? 0 variants, 1 variants, and 3 > variants and even more? By definition, you wouldn't be making any comparison if there are 0 variants. 1 variant means all the parents are identical, so whichever parent you are interested in, the difference to the child is interesting---such a change can only come from the person who merged adding a change that no parent wanted to have. If many parents are different then showing the comparison with the final resolution from them is useful. The case that is not so interesting is when one set of parents had something (call it A), and the other set of parents had something else (B), and the result is A. There is no interesting merge conflict in there. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: understand Diff Formatting --cc flag? 2022-03-16 16:04 ` Junio C Hamano @ 2022-03-16 18:57 ` Andy Zhang 2022-03-16 19:00 ` Andy Zhang 1 sibling, 0 replies; 5+ messages in thread From: Andy Zhang @ 2022-03-16 18:57 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Thu, Mar 17, 2022 at 12:04 AM Junio C Hamano <gitster@pobox.com> wrote: > > Andy Zhang <zhgdrx@gmail.com> writes: > > > understand Diff Formatting --cc flag? > > > > hi, > > > > It is really too hard to understand Diff Formatting --cc flag. > > > > It is hard to understand"...hunks whose contents in the parents have > > only two variants..". > > > > My question is: > > 1)what does "variant" mean here? > > You may be comparing a merge of 5 parents into 1 child. There are 5 > pairwise comparison (parent#1 with the child, parent#2 with the > child, ..., parent#5 with the child). > > Among 5 parents, perhaps parent#1 and parent#2 had the same contents, > and parent#4 and parent#5 had the same contents, different from what > parent#1 and parent#3 had. You have 3 variants (parent#1's, #3's > and #4's; parent#2 has the same contents as #1, parent#5 has the > same contents as #4). > [Andy wrote:] as per your comments, The 3 variants are indeed into the following 3 groups. My question is: why can #1 appear inside multiple groups? A and B. <group-A> parent#1, #3, #4; <group-B> parent#2, #1; <group-C> parent#5, #4; > > > 2)what about all the other cases? 0 variants, 1 variants, and 3 > > variants and even more? > > By definition, you wouldn't be making any comparison if there are 0 > variants. 1 variant means all the parents are identical, so > whichever parent you are interested in, the difference to the child > is interesting---such a change can only come from the person who > merged adding a change that no parent wanted to have. If many > parents are different then showing the comparison with the final > resolution from them is useful. The case that is not so interesting > is when one set of parents had something (call it A), and the other > set of parents had something else (B), and the result is A. There is > no interesting merge conflict in there. > [Andy wrote:] can I explain "--cc" flag as: "--cc lists only either hunks which were modified from all parents, or hunks which were modified from at least two parents and they had different variants" ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: understand Diff Formatting --cc flag? 2022-03-16 16:04 ` Junio C Hamano 2022-03-16 18:57 ` Andy Zhang @ 2022-03-16 19:00 ` Andy Zhang 2022-03-16 19:39 ` Junio C Hamano 1 sibling, 1 reply; 5+ messages in thread From: Andy Zhang @ 2022-03-16 19:00 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Thu, Mar 17, 2022 at 12:04 AM Junio C Hamano <gitster@pobox.com> wrote: > > Andy Zhang <zhgdrx@gmail.com> writes: > > > understand Diff Formatting --cc flag? > > > > hi, > > > > It is really too hard to understand Diff Formatting --cc flag. > > > > It is hard to understand"...hunks whose contents in the parents have > > only two variants..". > > > > My question is: > > 1)what does "variant" mean here? > > You may be comparing a merge of 5 parents into 1 child. There are 5 > pairwise comparison (parent#1 with the child, parent#2 with the > child, ..., parent#5 with the child). > > Among 5 parents, perhaps parent#1 and parent#2 had the same contents, > and parent#4 and parent#5 had the same contents, different from what > parent#1 and parent#3 had. You have 3 variants (parent#1's, #3's > and #4's; parent#2 has the same contents as #1, parent#5 has the > same contents as #4). > [Andy wrote:] as per your comments, The 3 variants are indeed into the following 3 groups. My question is: why can #1 appear inside multiple groups? A and B. <group-A> parent#1, #3, #4; <group-B> parent#2, #1; <group-C> parent#5, #4; > > 2)what about all the other cases? 0 variants, 1 variants, and 3 > > variants and even more? > > By definition, you wouldn't be making any comparison if there are 0 > variants. 1 variant means all the parents are identical, so > whichever parent you are interested in, the difference to the child > is interesting---such a change can only come from the person who > merged adding a change that no parent wanted to have. If many > parents are different then showing the comparison with the final > resolution from them is useful. The case that is not so interesting > is when one set of parents had something (call it A), and the other > set of parents had something else (B), and the result is A. There is > no interesting merge conflict in there. > [Andy wrote:] can I explain "--cc" flag as: "--cc lists only either hunks which were modified from all parents, or hunks which were modified from at least two parents and they had different variants" ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: understand Diff Formatting --cc flag? 2022-03-16 19:00 ` Andy Zhang @ 2022-03-16 19:39 ` Junio C Hamano 0 siblings, 0 replies; 5+ messages in thread From: Junio C Hamano @ 2022-03-16 19:39 UTC (permalink / raw) To: Andy Zhang; +Cc: git Andy Zhang <zhgdrx@gmail.com> writes: >> Among 5 parents, perhaps parent#1 and parent#2 had the same contents, >> and parent#4 and parent#5 had the same contents, different from what >> parent#1 and parent#3 had. You have 3 variants (parent#1's, #3's >> and #4's; parent#2 has the same contents as #1, parent#5 has the >> same contents as #4). >> > > [Andy wrote:] as per your comments, The 3 variants are indeed into the > following 3 groups. > My question is: why can #1 appear inside multiple groups? A and B. > <group-A> parent#1, #3, #4; > <group-B> parent#2, #1; > <group-C> parent#5, #4; The three variants in my sample scenario were (A) used by #1, (B) used by #3, and (C) used by #4. #2 uses (A) and #5 uses (C). The contents of #1 does appear twice, in #1 itself and also in #2. That is what "#2 has the same contents as #1" means. > [Andy wrote:] can I explain "--cc" flag as: > "--cc lists only either hunks which were modified from all parents, or > hunks which were modified from at least two parents and they had > different variants" I do not have time to see if that matches the official explanation found in "git diff --help", which I just re-read and I think it gives the right definition. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-16 19:39 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-16 11:36 understand Diff Formatting --cc flag? Andy Zhang 2022-03-16 16:04 ` Junio C Hamano 2022-03-16 18:57 ` Andy Zhang 2022-03-16 19:00 ` Andy Zhang 2022-03-16 19:39 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).