Skip to content

Commit f60b1b7

Browse files
committed
feat: add gix merge commit --debug
This yields additional debugging information with details about detected conflicts.
1 parent a52c7a0 commit f60b1b7

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

gitoxide-core/src/repository/merge/commit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn commit(
1818
format,
1919
file_favor,
2020
in_memory,
21+
debug,
2122
}: Options,
2223
) -> anyhow::Result<()> {
2324
if format != OutputFormat::Human {
@@ -63,6 +64,9 @@ pub fn commit(
6364
writeln!(out, "{tree_id} (wrote {written} trees)")?;
6465
}
6566

67+
if debug {
68+
writeln!(err, "{:#?}", &res.conflicts)?;
69+
}
6670
if !has_conflicts {
6771
writeln!(err, "{} possibly resolved conflicts", res.conflicts.len())?;
6872
}

gitoxide-core/src/repository/merge/tree.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub struct Options {
44
pub format: OutputFormat,
55
pub file_favor: Option<gix::merge::tree::FileFavor>,
66
pub in_memory: bool,
7+
pub debug: bool,
78
}
89

910
pub(super) mod function {
@@ -29,6 +30,7 @@ pub(super) mod function {
2930
format,
3031
file_favor,
3132
in_memory,
33+
debug,
3234
}: Options,
3335
) -> anyhow::Result<()> {
3436
if format != OutputFormat::Human {
@@ -77,6 +79,9 @@ pub(super) mod function {
7779
writeln!(out, "{tree_id} (wrote {written} trees)")?;
7880
}
7981

82+
if debug {
83+
writeln!(err, "{:#?}", &res.conflicts)?;
84+
}
8085
if !has_conflicts {
8186
writeln!(err, "{} possibly resolved conflicts", res.conflicts.len())?;
8287
}

src/plumbing/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub fn main() -> Result<()> {
174174
merge::SubCommands::Tree {
175175
in_memory,
176176
file_favor,
177+
debug,
177178
ours,
178179
base,
179180
theirs,
@@ -196,13 +197,15 @@ pub fn main() -> Result<()> {
196197
format,
197198
file_favor: file_favor.map(Into::into),
198199
in_memory,
200+
debug,
199201
},
200202
)
201203
},
202204
),
203205
merge::SubCommands::Commit {
204206
in_memory,
205207
file_favor,
208+
debug,
206209
ours,
207210
theirs,
208211
} => prepare_and_run(
@@ -223,6 +226,7 @@ pub fn main() -> Result<()> {
223226
format,
224227
file_favor: file_favor.map(Into::into),
225228
in_memory,
229+
debug,
226230
},
227231
)
228232
},

src/plumbing/options/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ pub mod merge {
420420
/// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
421421
#[clap(long, short = 'f')]
422422
file_favor: Option<FileFavor>,
423+
/// Print additional information about conflicts for debugging.
424+
#[clap(long, short = 'd')]
425+
debug: bool,
423426

424427
/// A revspec to our treeish.
425428
#[clap(value_name = "OURS", value_parser = crate::shared::AsBString)]
@@ -441,6 +444,9 @@ pub mod merge {
441444
/// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
442445
#[clap(long, short = 'f')]
443446
file_favor: Option<FileFavor>,
447+
/// Print additional information about conflicts for debugging.
448+
#[clap(long, short = 'd')]
449+
debug: bool,
444450

445451
/// A revspec to our committish.
446452
#[clap(value_name = "OURS", value_parser = crate::shared::AsBString)]

0 commit comments

Comments
 (0)