Skip to content

Commit

Permalink
conflicts: long markers if file contains marker-like lines
Browse files Browse the repository at this point in the history
If a file contains lines which look like conflict markers, then we need
to make the real conflict markers longer so that the materialized
conflicts can be parsed unambiguously. For instance, if we have a file
explaining the differences between Jujutsu's conflict markers and Git's
conflict markers, it could produce a conflict with long markers like
this:

```
<<<<<<<<<<< Conflict 1 of 1
%%%%%%%%%%% Changes from base to side jj-vcs#1
-Git's conflict markers look like this:
+Unlike Jujutsu, Git's conflict markers look like this:
+++++++++++ Contents of side jj-vcs#2
Jujutsu uses different conflict markers than Git, which just shows the
sides of a conflict without a diff:
>>>>>>>>>>> Conflict 1 of 1 ends

<<<<<<<
left
=======
right
>>>>>>>
```

We need to allow conflict markers to be longer than strictly necessary,
because imagine that we are in the process of resolving the conflict
shown above, and we remove the example of Git's conflict markers:

```
<<<<<<<<<<< Conflict 1 of 1
%%%%%%%%%%% Changes from base to side jj-vcs#1
-Git's conflict markers look like this:
+Unlike Jujutsu, Git's conflict markers look like this:
+++++++++++ Contents of side jj-vcs#2
Jujutsu uses different conflict markers than Git, which just shows the
sides of a conflict without a diff:
>>>>>>>>>>> Conflict 1 of 1 ends
```

Now, there is no reason for the conflict markers to be longer than 7
characters, since the text which looked like conflict markers has been
removed. We still want this file to be parsed correctly as a conflict
though, so we need to allow markers which are longer than necessary.
  • Loading branch information
scott2000 committed Nov 25, 2024
1 parent 15127bd commit f45ad03
Show file tree
Hide file tree
Showing 2 changed files with 252 additions and 83 deletions.
Loading

0 comments on commit f45ad03

Please sign in to comment.