merge-tree: move logic for existing merge into new function

In preparation for adding a non-trivial merge capability to merge-tree, move the existing merge logic for trivial merges into a new function. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jun 18, 2022 at 00:20 UTC 55e48f6bf76f9038eef1a6926533a7c30a53c923
1 file changed +8 -4
builtin/merge-tree.c
+8 -4
@@ -366,15 +366,12 @@ static void *get_tree_descriptor(struct repository *r,
366 return buf;
367 }
368
369 -int cmd_merge_tree(int argc, const char **argv, const char *prefix)
369 +static int trivial_merge(int argc, const char **argv)
370 {
371 struct repository *r = the_repository;
372 struct tree_desc t[3];
373 void *buf1, *buf2, *buf3;
374
375 - if (argc != 4)
376 - usage(merge_tree_usage);
377 -
375 buf1 = get_tree_descriptor(r, t+0, argv[1]);
376 buf2 = get_tree_descriptor(r, t+1, argv[2]);
377 buf3 = get_tree_descriptor(r, t+2, argv[3]);
@@ -386,3 +383,10 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
383 show_result();
384 return 0;
385 }
386 +
387 +int cmd_merge_tree(int argc, const char **argv, const char *prefix)
388 +{
389 + if (argc != 4)
390 + usage(merge_tree_usage);
391 + return trivial_merge(argc, argv);
392 +}