Skip to content

Commit 7290ef5

Browse files
mhaggergitster
authored andcommitted
submodule: rewrite to take an object_id argument
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 580b04e commit 7290ef5

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

submodule.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,18 @@ void set_config_fetch_recurse_submodules(int value)
422422
config_fetch_recurse_submodules = value;
423423
}
424424

425-
static int has_remote(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
425+
static int has_remote(const char *refname, const struct object_id *oid,
426+
int flags, void *cb_data)
426427
{
427428
return 1;
428429
}
429430

430431
static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
431432
{
432-
struct each_ref_fn_sha1_adapter wrapped_has_remote =
433-
{has_remote, NULL};
434-
435433
if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
436434
return 0;
437435

438-
if (for_each_remote_ref_submodule(path, each_ref_fn_adapter, &wrapped_has_remote) > 0) {
436+
if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
439437
struct child_process cp = CHILD_PROCESS_INIT;
440438
const char *argv[] = {"rev-list", NULL, "--not", "--remotes", "-n", "1" , NULL};
441439
struct strbuf buf = STRBUF_INIT;
@@ -522,13 +520,10 @@ int find_unpushed_submodules(unsigned char new_sha1[20],
522520

523521
static int push_submodule(const char *path)
524522
{
525-
struct each_ref_fn_sha1_adapter wrapped_has_remote =
526-
{has_remote, NULL};
527-
528523
if (add_submodule_odb(path))
529524
return 1;
530525

531-
if (for_each_remote_ref_submodule(path, each_ref_fn_adapter, &wrapped_has_remote) > 0) {
526+
if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
532527
struct child_process cp = CHILD_PROCESS_INIT;
533528
const char *argv[] = {"push", NULL};
534529

@@ -622,20 +617,17 @@ static void submodule_collect_changed_cb(struct diff_queue_struct *q,
622617
}
623618
}
624619

625-
static int add_sha1_to_array(const char *ref, const unsigned char *sha1,
620+
static int add_sha1_to_array(const char *ref, const struct object_id *oid,
626621
int flags, void *data)
627622
{
628-
sha1_array_append(data, sha1);
623+
sha1_array_append(data, oid->hash);
629624
return 0;
630625
}
631626

632627
void check_for_new_submodule_commits(unsigned char new_sha1[20])
633628
{
634629
if (!initialized_fetch_ref_tips) {
635-
struct each_ref_fn_sha1_adapter wrapped_add_sha1_to_array =
636-
{add_sha1_to_array, &ref_tips_before_fetch};
637-
638-
for_each_ref(each_ref_fn_adapter, &wrapped_add_sha1_to_array);
630+
for_each_ref(add_sha1_to_array, &ref_tips_before_fetch);
639631
initialized_fetch_ref_tips = 1;
640632
}
641633

0 commit comments

Comments
 (0)