Skip to content

Commit

Permalink
feat: add gix merge commit --debug
Browse files Browse the repository at this point in the history
This yields additional debugging information with details about detected conflicts.
  • Loading branch information
Byron committed Nov 24, 2024
1 parent cd61c25 commit 0a5993f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gitoxide-core/src/repository/merge/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn commit(
format,
file_favor,
in_memory,
debug,
}: Options,
) -> anyhow::Result<()> {
if format != OutputFormat::Human {
Expand Down Expand Up @@ -63,6 +64,9 @@ pub fn commit(
writeln!(out, "{tree_id} (wrote {written} trees)")?;
}

if debug {
writeln!(err, "{:#?}", &res.conflicts)?;
}
if !has_conflicts {
writeln!(err, "{} possibly resolved conflicts", res.conflicts.len())?;
}
Expand Down
5 changes: 5 additions & 0 deletions gitoxide-core/src/repository/merge/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub struct Options {
pub format: OutputFormat,
pub file_favor: Option<gix::merge::tree::FileFavor>,
pub in_memory: bool,
pub debug: bool,
}

pub(super) mod function {
Expand All @@ -29,6 +30,7 @@ pub(super) mod function {
format,
file_favor,
in_memory,
debug,
}: Options,
) -> anyhow::Result<()> {
if format != OutputFormat::Human {
Expand Down Expand Up @@ -77,6 +79,9 @@ pub(super) mod function {
writeln!(out, "{tree_id} (wrote {written} trees)")?;
}

if debug {
writeln!(err, "{:#?}", &res.conflicts)?;
}
if !has_conflicts {
writeln!(err, "{} possibly resolved conflicts", res.conflicts.len())?;
}
Expand Down
4 changes: 4 additions & 0 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub fn main() -> Result<()> {
merge::SubCommands::Tree {
in_memory,
file_favor,
debug,
ours,
base,
theirs,
Expand All @@ -196,13 +197,15 @@ pub fn main() -> Result<()> {
format,
file_favor: file_favor.map(Into::into),
in_memory,
debug,
},
)
},
),
merge::SubCommands::Commit {
in_memory,
file_favor,
debug,
ours,
theirs,
} => prepare_and_run(
Expand All @@ -223,6 +226,7 @@ pub fn main() -> Result<()> {
format,
file_favor: file_favor.map(Into::into),
in_memory,
debug,
},
)
},
Expand Down
6 changes: 6 additions & 0 deletions src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ pub mod merge {
/// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
#[clap(long, short = 'f')]
file_favor: Option<FileFavor>,
/// Print additional information about conflicts for debugging.
#[clap(long, short = 'd')]
debug: bool,

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

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

0 comments on commit 0a5993f

Please sign in to comment.