shallow: rewrite functions to take object_id arguments

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 580b04ef98b366b71491ad816bacd02bfe64b4f9
1 file changed +11 -18
shallow.c
+11 -18
@@ -475,11 +475,10 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
475 free(tmp);
476 }
477
478 -static int mark_uninteresting(const char *refname,
479 - const unsigned char *sha1,
478 +static int mark_uninteresting(const char *refname, const struct object_id *oid,
479 int flags, void *cb_data)
480 {
482 - struct commit *commit = lookup_commit_reference_gently(sha1, 1);
481 + struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
482 if (!commit)
483 return 0;
484 commit->object.flags |= UNINTERESTING;
@@ -512,8 +511,6 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
511 unsigned int i, nr;
512 int *shallow, nr_shallow = 0;
513 struct paint_info pi;
515 - struct each_ref_fn_sha1_adapter wrapped_mark_uninteresting =
516 - {mark_uninteresting, NULL};
514
515 trace_printf_key(&trace_shallow, "shallow: assign_shallow_commits_to_refs\n");
516 shallow = xmalloc(sizeof(*shallow) * (info->nr_ours + info->nr_theirs));
@@ -544,8 +541,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
541 * connect to old refs. If not (e.g. force ref updates) it'll
542 * have to go down to the current shallow commits.
543 */
547 - head_ref(each_ref_fn_adapter, &wrapped_mark_uninteresting);
548 - for_each_ref(each_ref_fn_adapter, &wrapped_mark_uninteresting);
544 + head_ref(mark_uninteresting, NULL);
545 + for_each_ref(mark_uninteresting, NULL);
546
547 /* Mark potential bottoms so we won't go out of bound */
548 for (i = 0; i < nr_shallow; i++) {
@@ -586,12 +583,12 @@ struct commit_array {
583 int nr, alloc;
584 };
585
589 -static int add_ref(const char *refname,
590 - const unsigned char *sha1, int flags, void *cb_data)
586 +static int add_ref(const char *refname, const struct object_id *oid,
587 + int flags, void *cb_data)
588 {
589 struct commit_array *ca = cb_data;
590 ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
594 - ca->commits[ca->nr] = lookup_commit_reference_gently(sha1, 1);
591 + ca->commits[ca->nr] = lookup_commit_reference_gently(oid->hash, 1);
592 if (ca->commits[ca->nr])
593 ca->nr++;
594 return 0;
@@ -620,8 +617,6 @@ static void post_assign_shallow(struct shallow_info *info,
617 int dst, i, j;
618 int bitmap_nr = (info->ref->nr + 31) / 32;
619 struct commit_array ca;
623 - struct each_ref_fn_sha1_adapter wrapped_add_ref =
624 - {add_ref, &ca};
620
621 trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
622 if (ref_status)
@@ -645,8 +640,8 @@ static void post_assign_shallow(struct shallow_info *info,
640 info->nr_theirs = dst;
641
642 memset(&ca, 0, sizeof(ca));
648 - head_ref(each_ref_fn_adapter, &wrapped_add_ref);
649 - for_each_ref(each_ref_fn_adapter, &wrapped_add_ref);
643 + head_ref(add_ref, &ca);
644 + for_each_ref(add_ref, &ca);
645
646 /* Remove unreachable shallow commits from "ours" */
647 for (i = dst = 0; i < info->nr_ours; i++) {
@@ -678,12 +673,10 @@ int delayed_reachability_test(struct shallow_info *si, int c)
673
674 if (!si->commits) {
675 struct commit_array ca;
681 - struct each_ref_fn_sha1_adapter wrapped_add_ref =
682 - {add_ref, &ca};
676
677 memset(&ca, 0, sizeof(ca));
685 - head_ref(each_ref_fn_adapter, &wrapped_add_ref);
686 - for_each_ref(each_ref_fn_adapter, &wrapped_add_ref);
678 + head_ref(add_ref, &ca);
679 + for_each_ref(add_ref, &ca);
680 si->commits = ca.commits;
681 si->nr_commits = ca.nr;
682 }