submodule: convert merge_submodule to use struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 6 May 2017 22:09:57 +0000 (22:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2017 06:12:56 +0000 (15:12 +0900)
This is a caller of lookup_commit_reference, which we will convert
later.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
submodule.c
submodule.h
index 9d6fd577e27ee5ec51b9f71c9f321b50a4af1803..1315a45b9388a133228d5fe7749d4a994390f880 100644 (file)
@@ -994,11 +994,11 @@ static int merge_file_1(struct merge_options *o,
                                return ret;
                        result->clean = (merge_status == 0);
                } else if (S_ISGITLINK(a->mode)) {
-                       result->clean = merge_submodule(result->oid.hash,
+                       result->clean = merge_submodule(&result->oid,
                                                       one->path,
-                                                      one->oid.hash,
-                                                      a->oid.hash,
-                                                      b->oid.hash,
+                                                      &one->oid,
+                                                      &a->oid,
+                                                      &b->oid,
                                                       !o->call_depth);
                } else if (S_ISLNK(a->mode)) {
                        oidcpy(&result->oid, &a->oid);
index d3299e29c0855b8503f444f659e2b24bba8ecb1f..9bdd5f6055623333a13c768acdac759ed2ebb41b 100644 (file)
@@ -1566,9 +1566,9 @@ static void print_commit(struct commit *commit)
 #define MERGE_WARNING(path, msg) \
        warning("Failed to merge submodule %s (%s)", path, msg);
 
-int merge_submodule(unsigned char result[20], const char *path,
-                   const unsigned char base[20], const unsigned char a[20],
-                   const unsigned char b[20], int search)
+int merge_submodule(struct object_id *result, const char *path,
+                   const struct object_id *base, const struct object_id *a,
+                   const struct object_id *b, int search)
 {
        struct commit *commit_base, *commit_a, *commit_b;
        int parent_count;
@@ -1577,14 +1577,14 @@ int merge_submodule(unsigned char result[20], const char *path,
        int i;
 
        /* store a in result in case we fail */
-       hashcpy(result, a);
+       oidcpy(result, a);
 
        /* we can not handle deletion conflicts */
-       if (is_null_sha1(base))
+       if (is_null_oid(base))
                return 0;
-       if (is_null_sha1(a))
+       if (is_null_oid(a))
                return 0;
-       if (is_null_sha1(b))
+       if (is_null_oid(b))
                return 0;
 
        if (add_submodule_odb(path)) {
@@ -1592,9 +1592,9 @@ int merge_submodule(unsigned char result[20], const char *path,
                return 0;
        }
 
-       if (!(commit_base = lookup_commit_reference(base)) ||
-           !(commit_a = lookup_commit_reference(a)) ||
-           !(commit_b = lookup_commit_reference(b))) {
+       if (!(commit_base = lookup_commit_reference(base->hash)) ||
+           !(commit_a = lookup_commit_reference(a->hash)) ||
+           !(commit_b = lookup_commit_reference(b->hash))) {
                MERGE_WARNING(path, "commits not present");
                return 0;
        }
@@ -1608,11 +1608,11 @@ int merge_submodule(unsigned char result[20], const char *path,
 
        /* Case #1: a is contained in b or vice versa */
        if (in_merge_bases(commit_a, commit_b)) {
-               hashcpy(result, b);
+               oidcpy(result, b);
                return 1;
        }
        if (in_merge_bases(commit_b, commit_a)) {
-               hashcpy(result, a);
+               oidcpy(result, a);
                return 1;
        }
 
index 1277480add48140c6bf8c6cbc51cb962e27637ae..89c2ed219177d07db5529bbac2d2a7996572f387 100644 (file)
@@ -84,10 +84,10 @@ extern int submodule_uses_gitfile(const char *path);
 #define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<1)
 #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)
 extern int bad_to_remove_submodule(const char *path, unsigned flags);
-extern int merge_submodule(unsigned char result[20], const char *path,
-                          const unsigned char base[20],
-                          const unsigned char a[20],
-                          const unsigned char b[20], int search);
+extern int merge_submodule(struct object_id *result, const char *path,
+                          const struct object_id *base,
+                          const struct object_id *a,
+                          const struct object_id *b, int search);
 extern int find_unpushed_submodules(struct oid_array *commits,
                                    const char *remotes_name,
                                    struct string_list *needs_pushing);