]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-tree: move logic for existing merge into new function
authorElijah Newren <newren@gmail.com>
Sat, 18 Jun 2022 00:20:45 +0000 (00:20 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Jun 2022 23:10:05 +0000 (16:10 -0700)
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>
builtin/merge-tree.c

index 06f9eee9f7844c322705d6d333d90fdcdcaef26d..914ec960b7e36c20e90b7db91a66156cd65b2c9e 100644 (file)
@@ -366,15 +366,12 @@ static void *get_tree_descriptor(struct repository *r,
        return buf;
 }
 
-int cmd_merge_tree(int argc, const char **argv, const char *prefix)
+static int trivial_merge(int argc, const char **argv)
 {
        struct repository *r = the_repository;
        struct tree_desc t[3];
        void *buf1, *buf2, *buf3;
 
-       if (argc != 4)
-               usage(merge_tree_usage);
-
        buf1 = get_tree_descriptor(r, t+0, argv[1]);
        buf2 = get_tree_descriptor(r, t+1, argv[2]);
        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)
        show_result();
        return 0;
 }
+
+int cmd_merge_tree(int argc, const char **argv, const char *prefix)
+{
+       if (argc != 4)
+               usage(merge_tree_usage);
+       return trivial_merge(argc, argv);
+}