Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The base version of a merge conflict is ignored #565

Open
KevinWuWon opened this issue Sep 1, 2023 · 2 comments
Open

The base version of a merge conflict is ignored #565

KevinWuWon opened this issue Sep 1, 2023 · 2 comments

Comments

@KevinWuWon
Copy link

(1) A description of the issue. A screenshot is often helpful too.

The difft output for a merge conflict is not useful because it diffs the wrong things together. For branches X and Y, with common ancestor B, it shows a diff between X and Y.

image (3)

This is not useful information for the purpose of solving the merge conflict. It's impossible to tell from this output if the result should say motorbike vs car, or if it should say father vs parents.

It would be better to show two diffs: the first between B and X, and the second between B and Y.

See the output from delta, as an example:

image (4)

From this output, it's possible to deduce that the result should refer to motorbike and parents

(2) A copy of what you're diffing. If you're diffing files, include
the before and after files. If you're using difftastic with a VCS
repository (e.g. git), include the URL and commit hash.

difft story.txt

For the following story.txt (example taken from this article, which I highly recommend)

<<<<<<< HEAD
Alice asked her father if she could
borrow his motorbike. He said ok but told
||||||| 104f349
Alice asked her father if she could
borrow his car. He said ok but told
=======
Alice asked her parents if she could
borrow their car. They said ok but told
>>>>>>> master
her she had to be back by 11pm.

(3) The version of difftastic you're using (see difft --version) and
your operating system.

Difftastic 0.51.1
macOS 13.5

@Wilfred
Copy link
Owner

Wilfred commented Sep 1, 2023

Yeah, this would be a reasonable addition. Note that there's no guarantee that a base version is present, but I agree the diff3 is easier to reason about.

I'm not sure what's the best way to display this though. Difftastic assumes a 2-way diff, so if I simply all of base against the left and all of base against the right, you end up scrolling a lot to compare each case.

@jrray
Copy link

jrray commented Dec 6, 2023

I've been using a script I hacked together to generate two diffs and present them both with xxdiff, which looks like the delta example above.

image

What I decided on was to show just the first conflict section found in the file, and I will iterate on fixing each conflict, saving the file, and running this tool again to see the next conflict.

I would love to see difftastic have a command line option to make it behave similarly. I wouldn't want to see all the diffs all at once, I just want to see them one pair at a time as I'm working on resolving the conflicts. I would settle for two options to make it show either all the B -> X diffs at once or all the B -> Y diffs. But what is most important to me is being able to see the two diffs at the same time and visually check how to apply both changes correctly.

Sometimes a single logical code change gets broken up into multiple conflicts, and then going conflict-by-conflict doesn't work well. It would be mind blowing if there was a way to see a range of conflicts (by index number?) combined into a single pair of diffs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants