From 8c6da0167c6194ed4feb8c954bb674bbaf222033 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 26 Nov 2024 13:25:38 +0100 Subject: [PATCH] WIP: remerge-diff: suppress conflict marker labels TODO: Deliberate whether this makes sense only optionally, e.g. with `range-diff --diff-merges=remerge`. If so: How to do that? Do we need to avoid the spawned `git log` calls in `range-diff.c` for that, in which case we face a then-again-premature optimization again that I fixed in ab75a565b4c (log: --remerge-diff needs to keep around commit parents, 2024-11-08). Besides, that would need to be refactored into its own patch as it would otherwise over-extend the scope. TODO: add a test case that demonstrates how this is useful. TODO: explain in the commit message why this is useful. Signed-off-by: Johannes Schindelin --- log-tree.c | 1 + merge-ort.c | 6 +++++- merge-recursive.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/log-tree.c b/log-tree.c index 33eb96b50c58b1..3dce6bd9c15bc9 100644 --- a/log-tree.c +++ b/log-tree.c @@ -1025,6 +1025,7 @@ static int do_remerge_diff(struct rev_info *opt, init_ui_merge_options(&o, the_repository); o.show_rename_progress = 0; o.record_conflict_msgs_as_headers = 1; + o.suppress_conflict_labels = 1; o.msg_header_prefix = "remerge"; ctx.abbrev = DEFAULT_ABBREV; diff --git a/merge-ort.c b/merge-ort.c index 8b81153e8fe0f5..621ede6700cf09 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -2085,7 +2085,11 @@ static int merge_3way(struct merge_options *opt, } assert(pathnames[0] && pathnames[1] && pathnames[2] && opt->ancestor); - if (pathnames[0] == pathnames[1] && pathnames[1] == pathnames[2]) { + if (opt->suppress_conflict_labels) { + base = xstrdup(""); + name1 = xstrdup(""); + name2 = xstrdup(""); + } else if (pathnames[0] == pathnames[1] && pathnames[1] == pathnames[2]) { base = mkpathdup("%s", opt->ancestor); name1 = mkpathdup("%s", opt->branch1); name2 = mkpathdup("%s", opt->branch2); diff --git a/merge-recursive.h b/merge-recursive.h index 0b91f28f902279..b4b0fb0c4021c7 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -48,6 +48,7 @@ struct merge_options { const char *subtree_shift; unsigned renormalize : 1; unsigned record_conflict_msgs_as_headers : 1; + unsigned suppress_conflict_labels : 1; const char *msg_header_prefix; /* internal fields used by the implementation */