git/list[1] front-page[2] threads[3] people[4] search[5] about
 

'git show -c' omits hunk even though file was modified from all parents

From
RMRalph Maalouf <ralph.maalouf@caretrx.com>
Date
Jul 29, 2019, 18:20 UTC
Message-ID
<MN2PR13MB2607878CB0C1E351B83F006BEADD0@MN2PR13MB2607.namprd13.prod.outlook.com>
Git version 2.17.1

Commit C0 contains FileA which is empty. Both branchA and branchB point to C0.

From branchA I add the following contents to FileA (and then commit): --- One Two Three

Seven Eight Nine ---

From branchB I add the following contents to FileA (and then commit): --- One Four Three

Seven Ten Nine ---

Note: I use two newlines so that git merge sees two hunks.
Case1: 

From branchA I merge branchB and resolve the conflict as follows: --- One Two Four Three

Seven Eight Nine ---

As expected, 'git show -c' outputs the combined diff for both hunks, whereas 'git show -cc' only shows hunk1 and omits "uninteresting" hunk2.
Case2:

First 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): --- One Two Three

Seven Ten Nine ---

Then from branchA I merge branchB and resolve the conflict as follows (keeping only the changes from branchA): --- One Two Three

Seven Ten Nine ---

I 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. I 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.

If 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.

Thanks, Ralph

Next: Junio C Hamano
Message 1 of 5 in “'git show -c' omits hunk even though file was modified from all parents”
  1. Ralph MaaloufJul 29, 2019
  2. Junio C HamanoJul 29, 2019
  3. Ralph MaaloufJul 29, 2019
  4. Junio C HamanoJul 29, 2019
  5. Ralph MaaloufJul 29, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.