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

conflicts: escape conflict markers by making them longer #4969

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Nov 26, 2024

  1. conflicts: refactor conflict marker writing and parsing

    These changes make the code a bit more readable, and they will make it
    easier to have conflict markers of different lengths in the next commit.
    scott2000 committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    17576d1 View commit details
    Browse the repository at this point in the history
  2. conflicts: escape conflict markers by making them longer

    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.
    
    When parsing the conflict, we require that the conflict markers in the
    file are at least as long as the materialized conflict markers, and we
    only parse the longest conflict markers in the file.
    
    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 martinvonz#1
     Jujutsu uses different conflict markers than Git, which just shows the
    -sides of a conflict without a diff.
    +sides of a conflict without a diff:
    +
    +<<<<<<<
    +left
    +|||||||
    +base
    +=======
    +right
    +>>>>>>>
    +++++++++++ Contents of side martinvonz#2
    Jujutsu uses different conflict markers than Git:
    
    <<<<<<<
    %%%%%%%
    -base
    +left
    +++++++
    right
    >>>>>>>
    >>>>>>>>>>> Conflict 1 of 1 ends
    ```
    scott2000 committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    392188d View commit details
    Browse the repository at this point in the history
  3. conflicts: avoid long markers for Git-style conflicts

    Git materializes conflicts with 7-character markers even if the file
    already contains conflict markers, so it doesn't seem necessary to
    support generating Git-style conflicts with markers longer than 7
    characters. This also means that files which use "=======" as a header
    (e.g. some titles in Markdown) won't require long conflict markers.
    scott2000 committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    9f0be3b View commit details
    Browse the repository at this point in the history