git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Documentation bug (?) when describing `zdiff3` merge format
@ 2024-08-08  1:22 punk.lion0906
  2024-08-08  6:49 ` Johannes Sixt
  2024-08-08 17:22 ` Kyle Lippincott
  0 siblings, 2 replies; 5+ messages in thread
From: punk.lion0906 @ 2024-08-08  1:22 UTC (permalink / raw)
  To: git

The docs at https://git-scm.com/docs/git-merge#_how_conflicts_are_presented describe the following snippets in `diff3` and `zdiff3` style as equivalent. They do not seem equivalent to me, so either this is a mistake or the `zdiff3` style is counterintuitive needs a better explanation.

diff3 style:

```
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
<<<<<<< yours:sample.txt
or cleanly resolved because both sides changed the same way.
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
or cleanly resolved because both sides changed the same way.
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
```

zdiff3 style:

```
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
```

The problem is that, I believe, the "or cleanly resolved because both sides changed identically." sentence should not be part of the **base** in the latter example, since that whole line was moved outside the conflict.

I'd appreciate knowing which it is.

        Thanks,
             Ilya

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

* Re: Documentation bug (?) when describing `zdiff3` merge format
  2024-08-08  1:22 Documentation bug (?) when describing `zdiff3` merge format punk.lion0906
@ 2024-08-08  6:49 ` Johannes Sixt
  2024-08-08 16:19   ` Junio C Hamano
  2024-08-08 17:22 ` Kyle Lippincott
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Sixt @ 2024-08-08  6:49 UTC (permalink / raw)
  To: punk.lion0906; +Cc: git

Am 08.08.24 um 03:22 schrieb punk.lion0906@fastmail.com:
> The docs at
> https://git-scm.com/docs/git-merge#_how_conflicts_are_presented
> describe the following snippets in `diff3` and `zdiff3` style as
> equivalent. They do not seem equivalent to me, so either this is a
> mistake or the `zdiff3` style is counterintuitive needs a better
> explanation.

I don't think that the documentation wants to claim any equivalence. I
can only see it says that "diff3 shows the conflict like this", and
"zdiff3 shows the conflict like that".

> zdiff3 style:
> 
> ```
> Here are lines that are either unchanged from the common
> ancestor, or cleanly resolved because only one side changed,
> or cleanly resolved because both sides changed the same way.
> <<<<<<< yours:sample.txt
> Conflict resolution is hard;
> let's go shopping.
> ||||||| base:sample.txt
> or cleanly resolved because both sides changed identically.
> Conflict resolution is hard.
> =======
> Git makes conflict resolution easy.
>>>>>>>> theirs:sample.txt
> And here is another line that is cleanly resolved or unmodified.
> ```
> 
> The problem is that, I believe, the "or cleanly resolved because both
> sides changed identically." sentence should not be part of the
> **base** in the latter example, since that whole line was moved
> outside the conflict.
This is exactly the problem that zdiff3 has: There is no way to indicate
that some line in the common ancester was resolved identically and is
now outside the conflict markers. Do not use zdiff3 if you cannot live
with this deficiency. This is in fact not made explicit in the
documentation.

-- Hannes


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

* Re: Documentation bug (?) when describing `zdiff3` merge format
  2024-08-08  6:49 ` Johannes Sixt
@ 2024-08-08 16:19   ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2024-08-08 16:19 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: punk.lion0906, git

Johannes Sixt <j6t@kdbg.org> writes:

> This is exactly the problem that zdiff3 has: There is no way to indicate
> that some line in the common ancester was resolved identically and is
> now outside the conflict markers. Do not use zdiff3 if you cannot live
> with this deficiency. This is in fact not made explicit in the
> documentation.

Yes, indeed that is a problem and that is not I personally do not
touch it even with a 10ft pole.  We might want to stress it a bit
more to warn potential users in our documentation.

#leftoverbits then?

Thanks.

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

* Re: Documentation bug (?) when describing `zdiff3` merge format
  2024-08-08  1:22 Documentation bug (?) when describing `zdiff3` merge format punk.lion0906
  2024-08-08  6:49 ` Johannes Sixt
@ 2024-08-08 17:22 ` Kyle Lippincott
  2024-08-08 20:25   ` punk.lion0906
  1 sibling, 1 reply; 5+ messages in thread
From: Kyle Lippincott @ 2024-08-08 17:22 UTC (permalink / raw)
  To: punk.lion0906; +Cc: git

On Wed, Aug 7, 2024 at 6:22 PM <punk.lion0906@fastmail.com> wrote:
>
> The docs at https://git-scm.com/docs/git-merge#_how_conflicts_are_presented describe the following snippets in `diff3` and `zdiff3` style as equivalent. They do not seem equivalent to me, so either this is a mistake or the `zdiff3` style is counterintuitive needs a better explanation.
>
> diff3 style:
>
> ```
> Here are lines that are either unchanged from the common
> ancestor, or cleanly resolved because only one side changed,
> <<<<<<< yours:sample.txt
> or cleanly resolved because both sides changed the same way.
> Conflict resolution is hard;
> let's go shopping.
> ||||||| base:sample.txt
> or cleanly resolved because both sides changed identically.
> Conflict resolution is hard.
> =======
> or cleanly resolved because both sides changed the same way.
> Git makes conflict resolution easy.
> >>>>>>> theirs:sample.txt
> And here is another line that is cleanly resolved or unmodified.
> ```
>
> zdiff3 style:
>
> ```
> Here are lines that are either unchanged from the common
> ancestor, or cleanly resolved because only one side changed,
> or cleanly resolved because both sides changed the same way.
> <<<<<<< yours:sample.txt
> Conflict resolution is hard;
> let's go shopping.
> ||||||| base:sample.txt
> or cleanly resolved because both sides changed identically.
> Conflict resolution is hard.
> =======
> Git makes conflict resolution easy.
> >>>>>>> theirs:sample.txt
> And here is another line that is cleanly resolved or unmodified.
> ```
>
> The problem is that, I believe, the "or cleanly resolved because both sides changed identically." sentence should not be part of the **base** in the latter example, since that whole line was moved outside the conflict.

This line _still changed_, even though there were conflicts around it,
meaning that if we didn't have the "... identically" line in base, we
wouldn't see that this line was removed anywhere in the diff. I agree
with the other responders that this is awkward, as it means you can't
reconstruct the original 'base' version from these diff markers; if
you tried, you'd get a base version that has "or cleanly ... the same
way" followed by "or cleanly ... identically". For manual conflict
resolution where you generally won't ever keep 'base' or attempt to
reconstruct it, however, it seems fine to me if you're aware of it
happening.

>
>
> I'd appreciate knowing which it is.
>
>         Thanks,
>              Ilya
>

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

* Re: Documentation bug (?) when describing `zdiff3` merge format
  2024-08-08 17:22 ` Kyle Lippincott
@ 2024-08-08 20:25   ` punk.lion0906
  0 siblings, 0 replies; 5+ messages in thread
From: punk.lion0906 @ 2024-08-08 20:25 UTC (permalink / raw)
  To: Kyle Lippincott; +Cc: git

> This line _still changed_, even though there were conflicts around it,

Ah, thanks for pointing this out, I absolutely missed that. My mind parsed
"... identically" and "... the same way" in the same way.

Now the situation makes a bit more sense, I'm getting a sense of *what* `zdiff3` is doing, even though I still don't quite follow the why.

In any case, in my mind this is now a documentation bug where `zdiff3` is not explained as well as it could be. I don't understand the situation enough to provide the fix, though.

Thank you, everyone, for the help!
               Ilya.

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

end of thread, other threads:[~2024-08-08 20:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08  1:22 Documentation bug (?) when describing `zdiff3` merge format punk.lion0906
2024-08-08  6:49 ` Johannes Sixt
2024-08-08 16:19   ` Junio C Hamano
2024-08-08 17:22 ` Kyle Lippincott
2024-08-08 20:25   ` punk.lion0906

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