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: allow missing newlines at end of file (based on [noeol] marker) #5181

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* `[diff.<format>]` configuration now applies to `.diff().<format>()` commit
template methods.

* Conflicts at the end of files which don't end with a newline character are
now materialized in a way that can be parsed correctly.
[#3968](https://github.com/jj-vcs/jj/issues/3968)

## [0.25.0] - 2025-01-01

### Release highlights
Expand Down
30 changes: 30 additions & 0 deletions docs/conflicts.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,33 @@ New Heading
===========
>>>>>>>>>>>>>>> Conflict 1 of 1 ends
```

## Conflict with no newline at end of file

On POSIX systems, text files are generally assumed to be a series of lines, with
each line terminated by a newline character. However, some files may not end
with a newline character, and it's important that `jj` doesn't lose any
information about the contents of a file when materializing conflicts.

Therefore, when `jj` encounters a conflict involving a missing terminating
newline character, it will add a `[noeol]` marker to the start of the conflict
to indicate that there was a missing End-Of-Line (EOL) character, and it will
automatically add a newline character after every base and side of the conflict.

For instance, if a file originally contained "grape" as its last line with no
terminating newline character, and one person changed "grape" to "grapefruit",
while another person added the missing newline character, the resulting conflict
would look like this:

```
<<<<<<< Conflict 1 of 1 [noeol]
+++++++ Contents of side #1
grapefruit
%%%%%%% Changes from base to side #2
grape
+
>>>>>>> Conflict 1 of 1 ends
```

The correct resolution of this conflict would be "grapefruit" followed by a
terminating newline character.
Loading