submodule: convert merge_submodule to use struct object_id
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>
brian m. carlson committed
May 6, 2017 at 22:09 UTC
71f35d5cbc0336ca5dca6b638c31d96611d301a7
3 files changed
+20
-20
merge-recursive.c
+4
-4
@@ -994,11 +994,11 @@ static int merge_file_1(struct merge_options *o,
994
return ret;
995
result->clean = (merge_status == 0);
996
} else if (S_ISGITLINK(a->mode)) {
997
- result->clean = merge_submodule(result->oid.hash,
997
+ result->clean = merge_submodule(&result->oid,
998
one->path,
999
- one->oid.hash,
1000
- a->oid.hash,
1001
- b->oid.hash,
999
+ &one->oid,
1000
+ &a->oid,
1001
+ &b->oid,
1002
!o->call_depth);
1003
} else if (S_ISLNK(a->mode)) {
1004
oidcpy(&result->oid, &a->oid);
submodule.c
+12
-12
@@ -1566,9 +1566,9 @@ static void print_commit(struct commit *commit)
1566
#define MERGE_WARNING(path, msg) \
1567
warning("Failed to merge submodule %s (%s)", path, msg);
1568
1569
-int merge_submodule(unsigned char result[20], const char *path,
1570
- const unsigned char base[20], const unsigned char a[20],
1571
- const unsigned char b[20], int search)
1569
+int merge_submodule(struct object_id *result, const char *path,
1570
+ const struct object_id *base, const struct object_id *a,
1571
+ const struct object_id *b, int search)
1572
{
1573
struct commit *commit_base, *commit_a, *commit_b;
1574
int parent_count;
@@ -1577,14 +1577,14 @@ int merge_submodule(unsigned char result[20], const char *path,
1577
int i;
1578
1579
/* store a in result in case we fail */
1580
- hashcpy(result, a);
1580
+ oidcpy(result, a);
1581
1582
/* we can not handle deletion conflicts */
1583
- if (is_null_sha1(base))
1583
+ if (is_null_oid(base))
1584
return 0;
1585
- if (is_null_sha1(a))
1585
+ if (is_null_oid(a))
1586
return 0;
1587
- if (is_null_sha1(b))
1587
+ if (is_null_oid(b))
1588
return 0;
1589
1590
if (add_submodule_odb(path)) {
@@ -1592,9 +1592,9 @@ int merge_submodule(unsigned char result[20], const char *path,
1592
return 0;
1593
}
1594
1595
- if (!(commit_base = lookup_commit_reference(base)) ||
1596
- !(commit_a = lookup_commit_reference(a)) ||
1597
- !(commit_b = lookup_commit_reference(b))) {
1595
+ if (!(commit_base = lookup_commit_reference(base->hash)) ||
1596
+ !(commit_a = lookup_commit_reference(a->hash)) ||
1597
+ !(commit_b = lookup_commit_reference(b->hash))) {
1598
MERGE_WARNING(path, "commits not present");
1599
return 0;
1600
}
@@ -1608,11 +1608,11 @@ int merge_submodule(unsigned char result[20], const char *path,
1608
1609
/* Case #1: a is contained in b or vice versa */
1610
if (in_merge_bases(commit_a, commit_b)) {
1611
- hashcpy(result, b);
1611
+ oidcpy(result, b);
1612
return 1;
1613
}
1614
if (in_merge_bases(commit_b, commit_a)) {
1615
- hashcpy(result, a);
1615
+ oidcpy(result, a);
1616
return 1;
1617
}
1618
submodule.h
+4
-4
@@ -84,10 +84,10 @@ extern int submodule_uses_gitfile(const char *path);
84
#define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<1)
85
#define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)
86
extern int bad_to_remove_submodule(const char *path, unsigned flags);
87
-extern int merge_submodule(unsigned char result[20], const char *path,
88
- const unsigned char base[20],
89
- const unsigned char a[20],
90
- const unsigned char b[20], int search);
87
+extern int merge_submodule(struct object_id *result, const char *path,
88
+ const struct object_id *base,
89
+ const struct object_id *a,
90
+ const struct object_id *b, int search);
91
extern int find_unpushed_submodules(struct oid_array *commits,
92
const char *remotes_name,
93
struct string_list *needs_pushing);