Skip to content

Commit

Permalink
adapt to changes in gix-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 28, 2023
1 parent 13d898b commit 9faf3f3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
name: crates without feature toggles
- run: set +x; for feature in progress fs-walkdir-parallel parallel io-pipe crc32 zlib zlib-rust-backend fast-sha1 rustsha1 cache-efficiency-debug; do (cd gix-features && cargo build --features $feature --target ${{ matrix.target }}); done
name: features of gix-features
- run: set +x; for name in gix-diff gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
- run: set +x; for name in gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
name: crates with 'wasm' feature
- run: cd gix-pack && cargo build --all-features --target ${{ matrix.target }}
name: gix-pack with all features (including wasm)
2 changes: 1 addition & 1 deletion gix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ revparse-regex = ["regex", "revision"]

## Make it possible to diff blobs line by line. Note that this feature is integral for implementing tree-diffs as well due to the handling of rename-tracking,
## which relies on line-by-line diffs in some cases.
blob-diff = ["gix-diff/blob"]
blob-diff = ["gix-diff/blob", "attributes"]

## Make it possible to turn a tree into a stream of bytes, which can be decoded to entries and turned into various other formats.
worktree-stream = ["gix-worktree-stream", "attributes"]
Expand Down
8 changes: 8 additions & 0 deletions gix/src/object/tree/diff/for_each.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub enum Error {
ConfigureDiffAlgorithm(#[from] crate::config::diff::algorithm::Error),
#[error("Failure during rename tracking")]
RenameTracking(#[from] tracker::emit::Error),
#[error("Could not obtain worktree filter options")]
PipelineOptions(#[from] crate::filter::pipeline::options::Error),
#[error(transparent)]
CommandContext(#[from] crate::config::command_context::Error),
}

///
Expand Down Expand Up @@ -175,6 +179,10 @@ where
),
},
&self.src_tree.repo.objects,
&mut gix_filter::Pipeline::new(
self.src_tree.repo.command_context()?,
crate::filter::Pipeline::options(self.src_tree.repo)?,
),
|push| {
self.src_tree
.traverse()
Expand Down
2 changes: 1 addition & 1 deletion gix/src/repository/worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl crate::Repository {
let mut cache = self
.attributes_only(&index, gix_worktree::stack::state::attributes::Source::IdMapping)?
.detach();
let pipeline = gix_filter::Pipeline::new(repo.command_context()?, crate::filter::Pipeline::options(self)?);
let pipeline = gix_filter::Pipeline::new(self.command_context()?, crate::filter::Pipeline::options(self)?);
let objects = self.objects.clone().into_arc().expect("TBD error handling");
let stream = gix_worktree_stream::from_tree(
id,
Expand Down
8 changes: 5 additions & 3 deletions gix/tests/object/tree/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ mod track_rewrites {
insertions: 1,
before: 11,
after: 12,
similarity: 0.8888889
}),
"by similarity there is a diff"
);
Expand Down Expand Up @@ -529,6 +530,7 @@ mod track_rewrites {
insertions: 3,
before: 12,
after: 15,
similarity: 0.75
}),
"by similarity there is a diff"
);
Expand Down Expand Up @@ -589,12 +591,12 @@ mod track_rewrites {

let out = out.rewrites.expect("tracking enabled");
assert_eq!(stat, None, "similarity can't run");
assert_eq!(out.num_similarity_checks, 3);
assert_eq!(out.num_similarity_checks, 0);
assert_eq!(
out.num_similarity_checks_skipped_for_rename_tracking_due_to_limit, 0,
"no limit configured"
);
assert_eq!(out.num_similarity_checks_skipped_for_copy_tracking_due_to_limit, 57);
assert_eq!(out.num_similarity_checks_skipped_for_copy_tracking_due_to_limit, 19);

Ok(())
}
Expand Down Expand Up @@ -645,7 +647,7 @@ mod track_rewrites {
let out = out.rewrites.expect("tracking enabled");
assert_eq!(out.num_similarity_checks, 0);
assert_eq!(out.num_similarity_checks_skipped_for_rename_tracking_due_to_limit, 0);
assert_eq!(out.num_similarity_checks_skipped_for_copy_tracking_due_to_limit, 3);
assert_eq!(out.num_similarity_checks_skipped_for_copy_tracking_due_to_limit, 2);

Ok(())
}
Expand Down

0 comments on commit 9faf3f3

Please sign in to comment.