Skip to content

Commit

Permalink
adapt to changes in gix related rename tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 11, 2023
1 parent cb17738 commit 4d471cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
9 changes: 4 additions & 5 deletions gitoxide-core/src/query/engine/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use anyhow::{anyhow, bail};
use gix::objs::find::Error;
use gix::{
bstr::{BStr, BString, ByteSlice},
diff::rewrites::CopySource,
features::progress,
object::tree::diff::rewrites::CopySource,
parallel::{InOrderIter, SequenceId},
prelude::ObjectIdExt,
Count, Progress,
Expand Down Expand Up @@ -139,11 +139,10 @@ pub fn update(
});

let rewrites = {
let mut r =
gix::object::tree::diff::Rewrites::try_from_config(&repo.config_snapshot(), true)?.unwrap_or_default();
r.copies = Some(gix::object::tree::diff::rewrites::Copies {
let mut r = gix::diff::Rewrites::try_from_config(&repo.config_snapshot(), true)?.unwrap_or_default();
r.copies = Some(gix::diff::rewrites::Copies {
source: if find_copies_harder {
CopySource::FromSetOfModifiedFilesAndSourceTree
CopySource::FromSetOfModifiedFilesAndAllSources
} else {
CopySource::FromSetOfModifiedFiles
},
Expand Down
23 changes: 11 additions & 12 deletions gix/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,15 @@ pub mod rewrites {
/// `cb(destination, source)` is called for each item, either with `Some(source)` if it's
/// the destination of a copy or rename, or with `None` for source if no relation to other
/// items in the tracked set exist.
/// `find_blob(oid, buf) -> Result<BlobRef, E>` is used to access blob data for similarity checks
/// if required with data and is taken directly from the object database. Worktree filters and diff conversions
/// will be applied afterwards automatically.
/// `objects` is used to access blob data for similarity checks if required and is taken directly from the object database.
/// Worktree filters and diff conversions will be applied afterwards automatically.
/// `push_source_tree(push_fn: push(change, location))` is a function that is called when the entire tree of the source
/// should be added as modifications by calling `push` repeatedly to use for perfect copy tracking. Note that
/// `push` will panic if `change` is not a modification, and it's valid to not call `push` at all.
pub fn emit<PushSourceTreeFn, E>(
&mut self,
mut cb: impl FnMut(visit::Destination<'_, T>, Option<visit::Source<'_>>) -> gix_diff::tree::visit::Action,
objects: &dyn gix_object::Find,
objects: impl gix_object::Find,
mut push_source_tree: PushSourceTreeFn,
) -> Result<Outcome, emit::Error>
where
Expand All @@ -317,7 +316,7 @@ pub mod rewrites {
&mut cb,
self.rewrites.percentage,
out,
objects,
&objects,
)?;

if let Some(copies) = self.rewrites.copies {
Expand All @@ -326,7 +325,7 @@ pub mod rewrites {
&mut cb,
copies.percentage,
out,
objects,
&objects,
)?;

match copies.source {
Expand All @@ -348,7 +347,7 @@ pub mod rewrites {
&mut cb,
copies.percentage,
out,
objects,
&objects,
)?;
}
}
Expand Down Expand Up @@ -377,11 +376,11 @@ pub mod rewrites {
cb: &mut impl FnMut(visit::Destination<'_, T>, Option<visit::Source<'_>>) -> gix_diff::tree::visit::Action,
percentage: Option<f32>,
mut out: Outcome,
objects: &dyn gix_object::Find,
objects: impl gix_object::Find,
) -> Result<Outcome, emit::Error> {
// we try to cheaply reduce the set of possibilities first, before possibly looking more exhaustively.
let needs_second_pass = !needs_exact_match(percentage);
if self.match_pairs(cb, None /* by identity */, kind, &mut out, objects)?
if self.match_pairs(cb, None /* by identity */, kind, &mut out, &objects)?
== gix_diff::tree::visit::Action::Cancel
{
return Ok(out);
Expand All @@ -403,7 +402,7 @@ pub mod rewrites {
false
};
if !is_limited {
self.match_pairs(cb, percentage, kind, &mut out, objects)?;
self.match_pairs(cb, percentage, kind, &mut out, &objects)?;
}
}
Ok(out)
Expand All @@ -415,7 +414,7 @@ pub mod rewrites {
percentage: Option<f32>,
kind: visit::Kind,
stats: &mut Outcome,
objects: &dyn gix_object::Find,
objects: impl gix_object::Find,
) -> Result<gix_diff::tree::visit::Action, emit::Error> {
// TODO(perf): reuse object data and interner state and interned tokens, make these available to `find_match()`
let mut dest_ofs = 0;
Expand All @@ -433,7 +432,7 @@ pub mod rewrites {
percentage.map(|p| (p, self.diff_algo)),
kind,
stats,
objects,
&objects,
&mut self.buf1,
&mut self.buf2,
)?
Expand Down

0 comments on commit 4d471cd

Please sign in to comment.