git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* 'git show -c' omits hunk even though file was modified from all parents
@ 2019-07-29 18:20 Ralph Maalouf
  2019-07-29 18:58 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Ralph Maalouf @ 2019-07-29 18:20 UTC (permalink / raw)
  To: 'git@vger.kernel.org'

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 'git show -c' omits hunk even though file was modified from all parents
  2019-07-29 18:20 'git show -c' omits hunk even though file was modified from all parents Ralph Maalouf
@ 2019-07-29 18:58 ` Junio C Hamano
  2019-07-29 19:52   ` Ralph Maalouf
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-07-29 18:58 UTC (permalink / raw)
  To: Ralph Maalouf; +Cc: 'git@vger.kernel.org'

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

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

Yes, 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: 'git show -c' omits hunk even though file was modified from all parents
  2019-07-29 18:58 ` Junio C Hamano
@ 2019-07-29 19:52   ` Ralph Maalouf
  2019-07-29 21:46     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Ralph Maalouf @ 2019-07-29 19:52 UTC (permalink / raw)
  To: 'Junio C Hamano'; +Cc: 'git@vger.kernel.org'

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

diff --combined test1
index 02ef2b0,ffc05f2..59d575d
--- a/test1
+++ b/test1
@@@ -1,8 -1,8 +1,9 @@@
  One
 +Two
+ Four
  Three


  Seven
 -Ten
 +Eight
  Nine

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

Thanks,
Ralph

-----Original Message-----
From: Junio C Hamano <gitster@pobox.com> 
Sent: Monday, July 29, 2019 2:58 PM
To: Ralph Maalouf <ralph.maalouf@caretrx.com>
Cc: 'git@vger.kernel.org' <git@vger.kernel.org>
Subject: Re: 'git show -c' omits hunk even though file was modified from all parents

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

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

Yes, 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 'git show -c' omits hunk even though file was modified from all parents
  2019-07-29 19:52   ` Ralph Maalouf
@ 2019-07-29 21:46     ` Junio C Hamano
  2019-07-29 22:26       ` Ralph Maalouf
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-07-29 21:46 UTC (permalink / raw)
  To: Ralph Maalouf; +Cc: 'git@vger.kernel.org'

Ralph Maalouf <ralph.maalouf@caretrx.com> writes:

> "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.
>
> diff --combined test1
> index 02ef2b0,ffc05f2..59d575d
> --- a/test1
> +++ b/test1
> @@@ -1,8 -1,8 +1,9 @@@
>   One
>  +Two
> + Four
>   Three
>
>
>   Seven
>  -Ten
>  +Eight
>   Nine

The above is a single hunk (whose definition is the group of lines
delimited by @@@...@@@ lines).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: 'git show -c' omits hunk even though file was modified from all parents
  2019-07-29 21:46     ` Junio C Hamano
@ 2019-07-29 22:26       ` Ralph Maalouf
  0 siblings, 0 replies; 5+ messages in thread
From: Ralph Maalouf @ 2019-07-29 22:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: 'git@vger.kernel.org'

Ahh that clears it up for me. I incorrectly assumed that at minimum that each "<<<<<<HEAD" represented a hunk..

I searched for the definition of hunk in gitglossary but couldn't find it.

Thanks for the clarification!
Ralph

-----Original Message-----
From: Junio C Hamano <gitster@pobox.com> 
Sent: Monday, July 29, 2019 5:46 PM
To: Ralph Maalouf <ralph.maalouf@caretrx.com>
Cc: 'git@vger.kernel.org' <git@vger.kernel.org>
Subject: Re: 'git show -c' omits hunk even though file was modified from all parents

Ralph Maalouf <ralph.maalouf@caretrx.com> writes:

> "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.
>
> diff --combined test1
> index 02ef2b0,ffc05f2..59d575d
> --- a/test1
> +++ b/test1
> @@@ -1,8 -1,8 +1,9 @@@
>   One
>  +Two
> + Four
>   Three
>
>
>   Seven
>  -Ten
>  +Eight
>   Nine

The above is a single hunk (whose definition is the group of lines delimited by @@@...@@@ lines).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-29 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 18:20 'git show -c' omits hunk even though file was modified from all parents Ralph Maalouf
2019-07-29 18:58 ` Junio C Hamano
2019-07-29 19:52   ` Ralph Maalouf
2019-07-29 21:46     ` Junio C Hamano
2019-07-29 22:26       ` Ralph Maalouf

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git