Skip to content

Commit 62655b3

Browse files
committed
fix: Repository::tree_merge_options() now comes with rewrite tracking.
This is the way Git acts, as it's either configured, or defaults to the value coming from the `diff.renames` configuration.
1 parent f60b1b7 commit 62655b3

File tree

5 files changed

+115
-262
lines changed

5 files changed

+115
-262
lines changed

gix/src/diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub(crate) mod utils {
175175
new_rewrites_inner(config, lenient, &Diff::RENAMES, &Diff::RENAME_LIMIT)
176176
}
177177

178-
pub fn new_rewrites_inner(
178+
pub(crate) fn new_rewrites_inner(
179179
config: &gix_config::File<'static>,
180180
lenient: bool,
181181
renames: &'static crate::config::tree::diff::Renames,

gix/src/repository/merge.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,20 @@ impl Repository {
8989
/// Read all relevant configuration options to instantiate options for use in [`merge_trees()`](Self::merge_trees).
9090
pub fn tree_merge_options(&self) -> Result<crate::merge::tree::Options, tree_merge_options::Error> {
9191
Ok(gix_merge::tree::Options {
92-
rewrites: crate::diff::utils::new_rewrites_inner(
93-
&self.config.resolved,
94-
self.config.lenient_config,
95-
&tree::Merge::RENAMES,
96-
&tree::Merge::RENAME_LIMIT,
97-
)?,
92+
rewrites: Some(
93+
crate::diff::utils::new_rewrites_inner(
94+
&self.config.resolved,
95+
self.config.lenient_config,
96+
&tree::Merge::RENAMES,
97+
&tree::Merge::RENAME_LIMIT,
98+
)?
99+
.map(Ok)
100+
.or_else(|| {
101+
crate::diff::utils::new_rewrites(&self.config.resolved, self.config.lenient_config).transpose()
102+
})
103+
.transpose()?
104+
.unwrap_or_default(),
105+
),
98106
blob_merge: self.blob_merge_options()?,
99107
blob_merge_command_ctx: self.command_context()?,
100108
fail_on_conflict: None,

0 commit comments

Comments
 (0)