Skip to content

Commit 8d590f3

Browse files
committed
adapt to changes in gix
1 parent a43e563 commit 8d590f3

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

Diff for: gitoxide-core/src/repository/merge/tree.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::OutputFormat;
22

33
pub struct Options {
44
pub format: OutputFormat,
5-
pub resolve_content_merge: Option<gix::merge::blob::builtin_driver::text::Conflict>,
5+
pub file_favor: Option<gix::merge::tree::FileFavor>,
66
pub in_memory: bool,
77
}
88

@@ -12,8 +12,6 @@ pub(super) mod function {
1212
use anyhow::{anyhow, bail, Context};
1313
use gix::bstr::BString;
1414
use gix::bstr::ByteSlice;
15-
use gix::merge::blob::builtin_driver::binary;
16-
use gix::merge::blob::builtin_driver::text::Conflict;
1715
use gix::merge::tree::UnresolvedConflict;
1816
use gix::prelude::Write;
1917

@@ -29,7 +27,7 @@ pub(super) mod function {
2927
theirs: BString,
3028
Options {
3129
format,
32-
resolve_content_merge,
30+
file_favor,
3331
in_memory,
3432
}: Options,
3533
) -> anyhow::Result<()> {
@@ -44,17 +42,7 @@ pub(super) mod function {
4442
let (ours_ref, ours_id) = refname_and_tree(&repo, ours)?;
4543
let (theirs_ref, theirs_id) = refname_and_tree(&repo, theirs)?;
4644

47-
let mut options = repo.tree_merge_options()?;
48-
if let Some(resolve) = resolve_content_merge {
49-
options.blob_merge.text.conflict = resolve;
50-
options.blob_merge.resolve_binary_with = match resolve {
51-
Conflict::Keep { .. } => None,
52-
Conflict::ResolveWithOurs => Some(binary::ResolveWith::Ours),
53-
Conflict::ResolveWithTheirs => Some(binary::ResolveWith::Theirs),
54-
Conflict::ResolveWithUnion => None,
55-
};
56-
}
57-
45+
let options = repo.tree_merge_options()?.with_file_favor(file_favor);
5846
let base_id_str = base_id.to_string();
5947
let ours_id_str = ours_id.to_string();
6048
let theirs_id_str = theirs_id.to_string();

Diff for: justfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ check:
4646
if cargo check -p gix-packetline --all-features 2>/dev/null; then false; else true; fi
4747
if cargo check -p gix-transport --all-features 2>/dev/null; then false; else true; fi
4848
if cargo check -p gix-protocol --all-features 2>/dev/null; then false; else true; fi
49-
if cargo tree -p gix --no-default-features -i imara-diff 2>/dev/null; then false; else true; fi
49+
cargo tree -p gix --no-default-features -e normal -i imara-diff 2>&1 | grep warning # warning happens if nothing found, no exit code :/
5050
if cargo tree -p gix --no-default-features -i gix-protocol 2>/dev/null; then false; else true; fi
51-
if cargo tree -p gix --no-default-features -i gix-submodule 2>/dev/null; then false; else true; fi
52-
if cargo tree -p gix --no-default-features -i gix-pathspec 2>/dev/null; then false; else true; fi
53-
if cargo tree -p gix --no-default-features -i gix-filter 2>/dev/null; then false; else true; fi
51+
cargo tree -p gix --no-default-features -e normal -i gix-submodule 2>&1 | grep warning
52+
cargo tree -p gix --no-default-features -e normal -i gix-pathspec 2>&1 | grep warning
53+
cargo tree -p gix --no-default-features -e normal -i gix-filter 2>&1 | grep warning
5454
if cargo tree -p gix --no-default-features -i gix-credentials 2>/dev/null; then false; else true; fi
5555
cargo check --no-default-features --features lean
5656
cargo check --no-default-features --features lean-async

Diff for: src/plumbing/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn main() -> Result<()> {
173173
),
174174
merge::SubCommands::Tree {
175175
in_memory,
176-
resolve_content_with,
176+
file_favor,
177177
ours,
178178
base,
179179
theirs,
@@ -194,7 +194,7 @@ pub fn main() -> Result<()> {
194194
theirs,
195195
core::repository::merge::tree::Options {
196196
format,
197-
resolve_content_merge: resolve_content_with.map(Into::into),
197+
file_favor: file_favor.map(Into::into),
198198
in_memory,
199199
},
200200
)

Diff for: src/plumbing/options/mod.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,23 @@ pub mod merge {
367367
}
368368
}
369369

370+
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)]
371+
pub enum FileFavor {
372+
/// Use only ours in case of conflict.
373+
Ours,
374+
/// Use only theirs in case of conflict.
375+
Theirs,
376+
}
377+
378+
impl From<FileFavor> for gix::merge::tree::FileFavor {
379+
fn from(value: FileFavor) -> Self {
380+
match value {
381+
FileFavor::Ours => gix::merge::tree::FileFavor::Ours,
382+
FileFavor::Theirs => gix::merge::tree::FileFavor::Theirs,
383+
}
384+
}
385+
}
386+
370387
#[derive(Debug, clap::Parser)]
371388
#[command(about = "perform merges of various kinds")]
372389
pub struct Platform {
@@ -400,9 +417,9 @@ pub mod merge {
400417
/// Note that the resulting tree won't be available or inspectable.
401418
#[clap(long, short = 'm')]
402419
in_memory: bool,
403-
/// Decide how to resolve content conflicts. If unset, write conflict markers and fail.
404-
#[clap(long, short = 'c')]
405-
resolve_content_with: Option<ResolveWith>,
420+
/// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
421+
#[clap(long, short = 'f')]
422+
file_favor: Option<FileFavor>,
406423

407424
/// A revspec to our treeish.
408425
#[clap(value_name = "OURS", value_parser = crate::shared::AsBString)]

0 commit comments

Comments
 (0)