It does require a few allocations this way, but makes the code much
easier to parse for human readers.
Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
merge-recursive.c | 36 +++++++++++-------------------------
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 273ee79afa..3bd727995b 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1290,31 +1290,17 @@ static int handle_change_delete(struct merge_options *o,
if (!ret)
ret = update_file(o, 0, o_oid, o_mode, update_path);
} else {
- if (!alt_path) {
- if (!old_path) {
- output(o, 1, _("CONFLICT (%s/delete): %s deleted in %s "
- "and %s in %s. Version %s of %s left in tree."),
- change, path, delete_branch, change_past,
- change_branch, change_branch, path);
- } else {
- output(o, 1, _("CONFLICT (%s/delete): %s deleted in %s "
- "and %s to %s in %s. Version %s of %s left in tree."),
- change, old_path, delete_branch, change_past, path,
- change_branch, change_branch, path);
- }
- } else {
- if (!old_path) {
- output(o, 1, _("CONFLICT (%s/delete): %s deleted in %s "
- "and %s in %s. Version %s of %s left in tree at %s."),
- change, path, delete_branch, change_past,
- change_branch, change_branch, path, alt_path);
- } else {
- output(o, 1, _("CONFLICT (%s/delete): %s deleted in %s "
- "and %s to %s in %s. Version %s of %s left in tree at %s."),
- change, old_path, delete_branch, change_past, path,
- change_branch, change_branch, path, alt_path);
- }
- }
+ const char *deleted_path = old_path ? old_path : path;
+ char *supp1 = xstrfmt(old_path ? " to %s" : "", path);
+ char *supp2 = xstrfmt(alt_path ? " at %s" : "", alt_path);
+
+ output(o, 1, _("CONFLICT (%s/delete): %s deleted in %s "
+ "and %s%s in %s. Version %s of %s left in tree%s."),
+ change, deleted_path, delete_branch, change_past,
+ supp1, change_branch, change_branch, path, supp2);
+ free(supp1);
+ free(supp2);
+
/*
* No need to call update_file() on path when change_branch ==
* o->branch1 && !alt_path, since that would needlessly touch