submodule: rewrite to take an object_id argument

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed May 25, 2015 at 18:39 UTC 7290ef5898ce343006ede558cb5755d35947b585
1 file changed +7 -15
submodule.c
+7 -15
@@ -422,20 +422,18 @@ void set_config_fetch_recurse_submodules(int value)
422 config_fetch_recurse_submodules = value;
423 }
424
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)
427 {
428 return 1;
429 }
430
431 static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
432 {
432 - struct each_ref_fn_sha1_adapter wrapped_has_remote =
433 - {has_remote, NULL};
434 -
433 if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
434 return 0;
435
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) {
437 struct child_process cp = CHILD_PROCESS_INIT;
438 const char *argv[] = {"rev-list", NULL, "--not", "--remotes", "-n", "1" , NULL};
439 struct strbuf buf = STRBUF_INIT;
@@ -522,13 +520,10 @@ int find_unpushed_submodules(unsigned char new_sha1[20],
520
521 static int push_submodule(const char *path)
522 {
525 - struct each_ref_fn_sha1_adapter wrapped_has_remote =
526 - {has_remote, NULL};
527 -
523 if (add_submodule_odb(path))
524 return 1;
525
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) {
527 struct child_process cp = CHILD_PROCESS_INIT;
528 const char *argv[] = {"push", NULL};
529
@@ -622,20 +617,17 @@ static void submodule_collect_changed_cb(struct diff_queue_struct *q,
617 }
618 }
619
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,
621 int flags, void *data)
622 {
628 - sha1_array_append(data, sha1);
623 + sha1_array_append(data, oid->hash);
624 return 0;
625 }
626
627 void check_for_new_submodule_commits(unsigned char new_sha1[20])
628 {
629 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);
631 initialized_fetch_ref_tips = 1;
632 }
633