Skip to content

Commit 580b04e

Browse files
mhaggergitster
authored andcommitted
shallow: rewrite functions to take object_id arguments
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 9c5fe0b commit 580b04e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

shallow.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,10 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
475475
free(tmp);
476476
}
477477

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,
480479
int flags, void *cb_data)
481480
{
482-
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
481+
struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
483482
if (!commit)
484483
return 0;
485484
commit->object.flags |= UNINTERESTING;
@@ -512,8 +511,6 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
512511
unsigned int i, nr;
513512
int *shallow, nr_shallow = 0;
514513
struct paint_info pi;
515-
struct each_ref_fn_sha1_adapter wrapped_mark_uninteresting =
516-
{mark_uninteresting, NULL};
517514

518515
trace_printf_key(&trace_shallow, "shallow: assign_shallow_commits_to_refs\n");
519516
shallow = xmalloc(sizeof(*shallow) * (info->nr_ours + info->nr_theirs));
@@ -544,8 +541,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
544541
* connect to old refs. If not (e.g. force ref updates) it'll
545542
* have to go down to the current shallow commits.
546543
*/
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);
549546

550547
/* Mark potential bottoms so we won't go out of bound */
551548
for (i = 0; i < nr_shallow; i++) {
@@ -586,12 +583,12 @@ struct commit_array {
586583
int nr, alloc;
587584
};
588585

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)
591588
{
592589
struct commit_array *ca = cb_data;
593590
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);
595592
if (ca->commits[ca->nr])
596593
ca->nr++;
597594
return 0;
@@ -620,8 +617,6 @@ static void post_assign_shallow(struct shallow_info *info,
620617
int dst, i, j;
621618
int bitmap_nr = (info->ref->nr + 31) / 32;
622619
struct commit_array ca;
623-
struct each_ref_fn_sha1_adapter wrapped_add_ref =
624-
{add_ref, &ca};
625620

626621
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
627622
if (ref_status)
@@ -645,8 +640,8 @@ static void post_assign_shallow(struct shallow_info *info,
645640
info->nr_theirs = dst;
646641

647642
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);
650645

651646
/* Remove unreachable shallow commits from "ours" */
652647
for (i = dst = 0; i < info->nr_ours; i++) {
@@ -678,12 +673,10 @@ int delayed_reachability_test(struct shallow_info *si, int c)
678673

679674
if (!si->commits) {
680675
struct commit_array ca;
681-
struct each_ref_fn_sha1_adapter wrapped_add_ref =
682-
{add_ref, &ca};
683676

684677
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);
687680
si->commits = ca.commits;
688681
si->nr_commits = ca.nr;
689682
}

0 commit comments

Comments
 (0)