Skip to content

Commit f80f8de

Browse files
committed
Fix conflict markers glued to hunks lacking trailing newline
Vendor diffy 0.4.2 with a newline guard in both conflict-marker builders until a release contains the upstream fix (bmwill/diffy#85). Signed-off-by: Jochen Hunz <j.hunz@anchorpoint.app>
1 parent 4c523df commit f80f8de

24 files changed

Lines changed: 5719 additions & 4 deletions

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ repos:
2929
hooks:
3030
- id: end-of-file-fixer
3131
- id: trailing-whitespace
32+
# vendor/diffy is pristine upstream source; its diff tests contain
33+
# semantically significant trailing whitespace
34+
exclude: vendor/diffy
3235
- id: check-executables-have-shebangs
3336
# Ignore for now until executable flag handling is easier in Lore
3437
# - id: check-shebang-scripts-are-executable
@@ -45,8 +48,9 @@ repos:
4548
rev: v1.5.5
4649
hooks:
4750
- id: remove-tabs
48-
# lore-core/native uses clangformat, which expects to use tabs so leave that path alone
49-
exclude: lore-core/native
51+
# lore-core/native uses clangformat, which expects to use tabs so leave that path alone;
52+
# vendor/diffy is pristine upstream source (tab-indented LICENSE text)
53+
exclude: lore-core/native|vendor/diffy
5054

5155
- repo: https://github.com/shellcheck-py/shellcheck-py
5256
rev: v0.10.0.1

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,5 @@ debug-assertions = false
194194
debug-assertions = false
195195

196196
[patch.crates-io]
197+
diffy = { path = "vendor/diffy" }
197198
quinn-proto = { path = "vendor/quinn-proto" }

lore-revision/tests/merge.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ mod tests {
3535
assert_eq!(result_string, expected_string);
3636
}
3737

38+
#[test]
39+
fn test_conflict_without_trailing_newlines() {
40+
let base_string = "This is line 1.\nThis is line 2.";
41+
let mine_string = "This is line 1.\nThis is line 2 changed.";
42+
let theirs_string = "This is line 1.\nThis is line 2 also changed.";
43+
let expected_string = "This is line 1.\n<<<<<<< ours\nThis is line 2 changed.\n||||||| original\nThis is line 2.\n=======\nThis is line 2 also changed.\n>>>>>>> theirs\n";
44+
45+
let result_string =
46+
match merge3_text(base_string, mine_string, theirs_string, None, None, None) {
47+
Err(str) | Ok(str) => str,
48+
};
49+
50+
assert_eq!(result_string, expected_string);
51+
}
52+
3853
#[test]
3954
fn test_markers() {
4055
let base_string = "This is line 1.\nThis is line 2.\n";

vendor/diffy/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
Cargo.lock

vendor/diffy/CHANGELOG.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Changelog
2+
3+
## [0.4.2] - 2025-01-29
4+
5+
### Added
6+
- [#37](https://github.com/bmwill/diffy/pull/37) Allow configuring the "No
7+
newline at end of file" message from being printed when formatting a patch.
8+
- [#38](https://github.com/bmwill/diffy/pull/38) Add support for configuring
9+
`suppress_blank_empty`.
10+
11+
## [0.4.1] - 2025-01-29
12+
13+
### Added
14+
- [#36](https://github.com/bmwill/diffy/pull/36) Add ability to configure
15+
filenames when creating a patch with `DiffOptions`.
16+
17+
## [0.4.0] - 2024-06-14
18+
19+
### Fixed
20+
- [#28](https://github.com/bmwill/diffy/issues/28) Fixed an issue where
21+
conflicts were being omitted from merges.
22+
23+
### Added
24+
- [#26](https://github.com/bmwill/diffy/pull/26) Add ability to reverse a
25+
patch.
26+
27+
### Changed
28+
- [#29](https://github.com/bmwill/diffy/pull/29) Bump minimum supported rust
29+
version (msrv) to 1.62.1.
30+
- [#22](https://github.com/bmwill/diffy/pull/22) update nu-ansi-term dependency
31+
to 0.50.
32+
33+
## [0.3.0] - 2022-08-29
34+
35+
### Fixed
36+
- [#17](https://github.com/bmwill/diffy/issues/17) Fix an issue which resulted
37+
in a large slowdown when applying a patch with incorrect hunk headers.
38+
- [#18](https://github.com/bmwill/diffy/pull/18) Replace unmaintained ansi_term
39+
dependency with nu_ansi_term in order to address
40+
[RUSTSEC-2021-0139](https://rustsec.org/advisories/RUSTSEC-2021-0139).
41+
42+
### Changed
43+
- [#19](https://github.com/bmwill/diffy/pull/19) Bump minimum supported rust
44+
version (msrv) to 1.51.0.
45+
46+
## [0.2.2] - 2022-01-31
47+
48+
### Fixed
49+
- [#16](https://github.com/bmwill/diffy/issues/16) Fix an issue where patch
50+
files failed to parse when they contained hunks which were adjacent to one
51+
another.
52+
53+
## [0.2.1] - 2021-01-27
54+
55+
### Fixed
56+
- [#9](https://github.com/bmwill/diffy/issues/9) Fix an issue where the incorrect
57+
range was being used to index an array when calculating a merge resulting in a
58+
panic in some cases.
59+
60+
## [0.2.0] - 2020-07-07
61+
### Added
62+
- Support for working with potentially non-utf8 data with the addition of
63+
various `*_bytes` functions.
64+
- Support for writing both utf8 and non-utf8 patches into a writer `W: io::write`
65+
- Support for a minimum supported rust version (msrv) of 1.36.0.
66+
67+
### Changed
68+
- The `Patch` type is now generic across the text type, either `str` for utf8
69+
text and `[u8]` for potentially non-utf8 texts.
70+
- The filenames for the original and modified files of a patch are now
71+
optional. This means that patches which don't include filename headers
72+
(only include hunks) can now properly be parsed.
73+
74+
### Fixed
75+
- Quoted filenames which include escaped characters are now properly parsed.
76+
77+
## [0.1.1] - 2020-07-01
78+
### Added
79+
- `Patch`es can now be parsed from strings with `Patch::from_str`
80+
- A `Patch` can now be applied to a base image with `apply`
81+
82+
## [0.1.0] - 2020-06-30
83+
- Initial release.
84+
85+
[0.4.2]: https://github.com/bmwill/diffy/releases/tag/0.4.2
86+
[0.4.1]: https://github.com/bmwill/diffy/releases/tag/0.4.1
87+
[0.4.0]: https://github.com/bmwill/diffy/releases/tag/0.4.0
88+
[0.3.0]: https://github.com/bmwill/diffy/releases/tag/0.3.0
89+
[0.2.2]: https://github.com/bmwill/diffy/releases/tag/0.2.2
90+
[0.2.1]: https://github.com/bmwill/diffy/releases/tag/0.2.1
91+
[0.2.0]: https://github.com/bmwill/diffy/releases/tag/0.2.0
92+
[0.1.1]: https://github.com/bmwill/diffy/releases/tag/0.1.1
93+
[0.1.0]: https://github.com/bmwill/diffy/releases/tag/0.1.0

vendor/diffy/Cargo.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
2+
#
3+
# When uploading crates to the registry Cargo will automatically
4+
# "normalize" Cargo.toml files for maximal compatibility
5+
# with all versions of Cargo and also rewrite `path` dependencies
6+
# to registry (e.g., crates.io) dependencies.
7+
#
8+
# If you are reading this file be aware that the original Cargo.toml
9+
# will likely look very different (and much more reasonable).
10+
# See Cargo.toml.orig for the original contents.
11+
12+
[package]
13+
edition = "2021"
14+
rust-version = "1.62.1"
15+
name = "diffy"
16+
version = "0.4.2"
17+
authors = ["Brandon Williams <bwilliams.eng@gmail.com>"]
18+
build = false
19+
autobins = false
20+
autoexamples = false
21+
autotests = false
22+
autobenches = false
23+
description = "Tools for finding and manipulating differences between files"
24+
documentation = "https://docs.rs/diffy"
25+
readme = "README.md"
26+
keywords = [
27+
"diff",
28+
"patch",
29+
"merge",
30+
]
31+
categories = ["text-processing"]
32+
license = "MIT OR Apache-2.0"
33+
repository = "https://github.com/bmwill/diffy"
34+
35+
[lib]
36+
name = "diffy"
37+
path = "src/lib.rs"
38+
39+
[dependencies.nu-ansi-term]
40+
version = "0.50"
41+
42+
[workspace]

vendor/diffy/Cargo.toml.orig

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)