{"thread":{"id":"51547","subject":"'git show -c' omits hunk even though file was modified from all parents","startedAt":"2019-07-29T18:20:51Z","lastAt":"2019-07-29T22:26:46Z","messageCount":5,"participants":["Ralph Maalouf","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"379512","messageId":"MN2PR13MB2607878CB0C1E351B83F006BEADD0@MN2PR13MB2607.namprd13.prod.outlook.com","threadId":"51547","inReplyTo":null,"subject":"'git show -c' omits hunk even though file was modified from all parents","fromName":"Ralph Maalouf","fromEmail":"ralph.maalouf@caretrx.com","sentAt":"2019-07-29T18:20:44Z","receivedAt":"2019-07-29T18:20:51Z","isPatch":false,"sender":{"key":"ralph.maalouf@caretrx.com","avatar":null},"body":"Git version 2.17.1\n\nCommit C0 contains FileA which is empty.\nBoth branchA and branchB point to C0.\n\nFrom branchA I add the following contents to FileA (and then commit):\n---\nOne\nTwo\nThree\n\n\nSeven\nEight\nNine\n---\n\nFrom branchB I add the following contents to FileA (and then commit):\n---\nOne\nFour\nThree\n\n\nSeven\nTen\nNine\n---\n\nNote: I use two newlines so that git merge sees two hunks.\n\nCase1: \n\nFrom branchA I merge branchB and resolve the conflict as follows:\n---\nOne\nTwo\nFour\nThree\n\n\nSeven\nEight\nNine\n---\n\nAs expected, 'git show -c' outputs the combined diff for both hunks, whereas 'git show -cc' only shows hunk1 and omits \"uninteresting\" hunk2.\n\nCase2:\n\nFirst I amend branchA so that the second hunk is the same as in branchB (note that the first hunk is still different between the 2 branches):\n---\nOne\nTwo\nThree\n\n\nSeven\nTen\nNine\n---\n\nThen from branchA I merge branchB and resolve the conflict as follows (keeping only the changes from branchA):\n---\nOne\nTwo\nThree\n\n\nSeven\nTen\nNine\n---\n\nI was expecting `git show -c` to output the combined diff for \"uninteresting\" hunk1, just as it did for hunk2 in case1. But it doesn't.\nI realize that this is because fileA in the merge commit's tree is identical to what it was in branchA prior to the merge (so the output of 'git show -m' only outputs the diff for one parent). But I'm wondering if this is the intended behavior.\n\nIf it's not, then the '-c' section in 'man git log' that says \"it lists only files which were modified from all parents\" may be a bit confusing since this requirement seems to be met.\n\nThanks,\nRalph\n\n\n"},{"id":"379513","messageId":"xmqqd0hsvfb9.fsf@gitster-ct.c.googlers.com","threadId":"51547","inReplyTo":"MN2PR13MB2607878CB0C1E351B83F006BEADD0@MN2PR13MB2607.namprd13.prod.outlook.com","subject":"Re: 'git show -c' omits hunk even though file was modified from all parents","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-29T18:58:02Z","receivedAt":"2019-07-29T18:58:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"So in short, one side has 1/2/3//7/10/9 in fileA and the other side\nhas 1/4/3//7/10/9, and the result of the merge is recorded as\n1/2/3//7/10/9.\n\n> I realize that this is because fileA in the merge commit's tree is\n> identical to what it was in branchA prior to the merge (so the\n> output of 'git show -m' only outputs the diff for one parent). But\n> I'm wondering if this is the intended behavior.\n\nYes, that is very much intended.  We do not show hunks that match\none of the parents, and if there is no hunk to show, the path itself\nis not shown.\n"},{"id":"379516","messageId":"MN2PR13MB2607F47AC76601FC709A67A8EADD0@MN2PR13MB2607.namprd13.prod.outlook.com","threadId":"51547","inReplyTo":"xmqqd0hsvfb9.fsf@gitster-ct.c.googlers.com","subject":"RE: 'git show -c' omits hunk even though file was modified from all parents","fromName":"Ralph Maalouf","fromEmail":"ralph.maalouf@caretrx.com","sentAt":"2019-07-29T19:52:55Z","receivedAt":"2019-07-29T19:59:48Z","isPatch":false,"sender":{"key":"ralph.maalouf@caretrx.com","avatar":null},"body":"\"We do not show hunks that match one of the parents \". But in case 1 the second hunk matches one of the parents yet `git show -c` still outputs it.\n\ndiff --combined test1\nindex 02ef2b0,ffc05f2..59d575d\n--- a/test1\n+++ b/test1\n@@@ -1,8 -1,8 +1,9 @@@\n  One\n +Two\n+ Four\n  Three\n\n\n  Seven\n -Ten\n +Eight\n  Nine\n\nI guess the \"Furthermore, it lists only files which were modified from all parents.\" part explains it, but I still find the behavior to be counterintuitive.\n\nThanks,\nRalph\n\n-----Original Message-----\nFrom: Junio C Hamano <gitster@pobox.com> \nSent: Monday, July 29, 2019 2:58 PM\nTo: Ralph Maalouf <ralph.maalouf@caretrx.com>\nCc: 'git@vger.kernel.org' <git@vger.kernel.org>\nSubject: Re: 'git show -c' omits hunk even though file was modified from all parents\n\nSo in short, one side has 1/2/3//7/10/9 in fileA and the other side has 1/4/3//7/10/9, and the result of the merge is recorded as 1/2/3//7/10/9.\n\n> I realize that this is because fileA in the merge commit's tree is \n> identical to what it was in branchA prior to the merge (so the output \n> of 'git show -m' only outputs the diff for one parent). But I'm \n> wondering if this is the intended behavior.\n\nYes, that is very much intended.  We do not show hunks that match one of the parents, and if there is no hunk to show, the path itself is not shown.\n"},{"id":"379554","messageId":"xmqqsgqotsyi.fsf@gitster-ct.c.googlers.com","threadId":"51547","inReplyTo":"MN2PR13MB2607F47AC76601FC709A67A8EADD0@MN2PR13MB2607.namprd13.prod.outlook.com","subject":"Re: 'git show -c' omits hunk even though file was modified from all parents","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-29T21:46:13Z","receivedAt":"2019-07-29T21:46:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ralph Maalouf <ralph.maalouf@caretrx.com> writes:\n\n> \"We do not show hunks that match one of the parents \". But in case\n> 1 the second hunk matches one of the parents yet `git show -c`\n> still outputs it.\n>\n> diff --combined test1\n> index 02ef2b0,ffc05f2..59d575d\n> --- a/test1\n> +++ b/test1\n> @@@ -1,8 -1,8 +1,9 @@@\n>   One\n>  +Two\n> + Four\n>   Three\n>\n>\n>   Seven\n>  -Ten\n>  +Eight\n>   Nine\n\nThe above is a single hunk (whose definition is the group of lines\ndelimited by @@@...@@@ lines).\n"},{"id":"379559","messageId":"MN2PR13MB2607F98BF473C36A0C8F17ECEADD0@MN2PR13MB2607.namprd13.prod.outlook.com","threadId":"51547","inReplyTo":"xmqqsgqotsyi.fsf@gitster-ct.c.googlers.com","subject":"RE: 'git show -c' omits hunk even though file was modified from all parents","fromName":"Ralph Maalouf","fromEmail":"ralph.maalouf@caretrx.com","sentAt":"2019-07-29T22:26:39Z","receivedAt":"2019-07-29T22:26:46Z","isPatch":false,"sender":{"key":"ralph.maalouf@caretrx.com","avatar":null},"body":"Ahh that clears it up for me. I incorrectly assumed that at minimum that each \"<<<<<<HEAD\" represented a hunk..\n\nI searched for the definition of hunk in gitglossary but couldn't find it.\n\nThanks for the clarification!\nRalph\n\n-----Original Message-----\nFrom: Junio C Hamano <gitster@pobox.com> \nSent: Monday, July 29, 2019 5:46 PM\nTo: Ralph Maalouf <ralph.maalouf@caretrx.com>\nCc: 'git@vger.kernel.org' <git@vger.kernel.org>\nSubject: Re: 'git show -c' omits hunk even though file was modified from all parents\n\nRalph Maalouf <ralph.maalouf@caretrx.com> writes:\n\n> \"We do not show hunks that match one of the parents \". But in case\n> 1 the second hunk matches one of the parents yet `git show -c` still \n> outputs it.\n>\n> diff --combined test1\n> index 02ef2b0,ffc05f2..59d575d\n> --- a/test1\n> +++ b/test1\n> @@@ -1,8 -1,8 +1,9 @@@\n>   One\n>  +Two\n> + Four\n>   Three\n>\n>\n>   Seven\n>  -Ten\n>  +Eight\n>   Nine\n\nThe above is a single hunk (whose definition is the group of lines delimited by @@@...@@@ lines).\n"}]}