Skip to content

Commit f53f942

Browse files
committed
Merge branch 'imra-diff'
2 parents c9c1658 + 7d5fb3c commit f53f942

File tree

9 files changed

+120
-97
lines changed

9 files changed

+120
-97
lines changed

Diff for: Cargo.lock

+51-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: git-diff/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ authors = ["Sebastian Thiel <[email protected]>"]
88
edition = "2018"
99
include = ["src/**/*"]
1010

11+
[features]
12+
serde1 = ["serde", "git-hash/serde1", "git-object/serde1"]
13+
1114
[lib]
1215
doctest = false
1316

1417
[dependencies]
1518
git-hash = { version = "^0.9.11", path = "../git-hash" }
1619
git-object = { version = "^0.22.0", path = "../git-object" }
1720
thiserror = "1.0.32"
18-
similar = { version = "2.2.0", features = ["bytes"] }
21+
imara-diff = "0.1.3"
22+
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
1923

2024
[dev-dependencies]
2125
git-odb = { path = "../git-odb" }

Diff for: git-diff/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
pub mod tree;
77

88
///
9-
pub mod lines;
9+
pub mod text;

Diff for: git-diff/src/lines.rs

-25
This file was deleted.

Diff for: git-diff/src/text.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use git_object::bstr::BStr;
2+
/// The crate powering file diffs.
3+
pub use imara_diff as imara;
4+
pub use imara_diff::Algorithm;
5+
6+
/// Create a diff yielding the changes to turn `old` into `new` with `algorithm`. `make_input` obtains the `old` and `new`
7+
/// byte buffers and produces an interner, which is then passed to `make_sink` for creating a processor over the changes.
8+
///
9+
/// See [the `imara-diff` crate documentation][imara] for information on how to implement a [`Sink`][imara::Sink].
10+
pub fn with<'a, FnI, FnS, S>(
11+
old: &'a BStr,
12+
new: &'a BStr,
13+
algorithm: Algorithm,
14+
make_input: FnI,
15+
make_sink: FnS,
16+
) -> (imara::intern::InternedInput<&'a [u8]>, S::Out)
17+
where
18+
FnI: FnOnce(&'a [u8], &'a [u8]) -> imara::intern::InternedInput<&'a [u8]>,
19+
FnS: FnOnce(&imara::intern::InternedInput<&'a [u8]>) -> S,
20+
S: imara_diff::Sink,
21+
{
22+
let input = make_input(old.as_ref(), new.as_ref());
23+
let sink = make_sink(&input);
24+
let out = imara::diff(algorithm, &input, sink);
25+
(input, out)
26+
}

0 commit comments

Comments
 (0)