From 4d471cda49e7f95abdeee7b550ed5c49c141d401 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 1 Nov 2023 12:39:07 +0100 Subject: [PATCH] adapt to changes in `gix` related rename tracking --- gitoxide-core/src/query/engine/update.rs | 9 ++++----- gix/src/diff.rs | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/gitoxide-core/src/query/engine/update.rs b/gitoxide-core/src/query/engine/update.rs index 0e8281cf950..fc41effdd12 100644 --- a/gitoxide-core/src/query/engine/update.rs +++ b/gitoxide-core/src/query/engine/update.rs @@ -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, @@ -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 }, diff --git a/gix/src/diff.rs b/gix/src/diff.rs index ce0d5216b65..0d02863402a 100644 --- a/gix/src/diff.rs +++ b/gix/src/diff.rs @@ -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` 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( &mut self, mut cb: impl FnMut(visit::Destination<'_, T>, Option>) -> gix_diff::tree::visit::Action, - objects: &dyn gix_object::Find, + objects: impl gix_object::Find, mut push_source_tree: PushSourceTreeFn, ) -> Result where @@ -317,7 +316,7 @@ pub mod rewrites { &mut cb, self.rewrites.percentage, out, - objects, + &objects, )?; if let Some(copies) = self.rewrites.copies { @@ -326,7 +325,7 @@ pub mod rewrites { &mut cb, copies.percentage, out, - objects, + &objects, )?; match copies.source { @@ -348,7 +347,7 @@ pub mod rewrites { &mut cb, copies.percentage, out, - objects, + &objects, )?; } } @@ -377,11 +376,11 @@ pub mod rewrites { cb: &mut impl FnMut(visit::Destination<'_, T>, Option>) -> gix_diff::tree::visit::Action, percentage: Option, mut out: Outcome, - objects: &dyn gix_object::Find, + objects: impl gix_object::Find, ) -> Result { // 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); @@ -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) @@ -415,7 +414,7 @@ pub mod rewrites { percentage: Option, kind: visit::Kind, stats: &mut Outcome, - objects: &dyn gix_object::Find, + objects: impl gix_object::Find, ) -> Result { // TODO(perf): reuse object data and interner state and interned tokens, make these available to `find_match()` let mut dest_ofs = 0; @@ -433,7 +432,7 @@ pub mod rewrites { percentage.map(|p| (p, self.diff_algo)), kind, stats, - objects, + &objects, &mut self.buf1, &mut self.buf2, )?