remote: use commit_stack for sent_tips
Call commit_stack functions instead of effectively open-coding them. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 24, 2025 at 18:03 UTC
4455d4a2ea6e89b3f3cc50dc1d7435afac3e1e0d
1 file changed
+7
-13
remote.c
+7
-13
@@ -1381,12 +1381,7 @@ static struct ref **tail_ref(struct ref **head)
1381
return tail;
1382
}
1383
1384
-struct tips {
1385
- struct commit **tip;
1386
- size_t nr, alloc;
1387
-};
1388
-
1389
-static void add_to_tips(struct tips *tips, const struct object_id *oid)
1384
+static void add_to_tips(struct commit_stack *tips, const struct object_id *oid)
1385
{
1386
struct commit *commit;
1387
@@ -1396,8 +1391,7 @@ static void add_to_tips(struct tips *tips, const struct object_id *oid)
1391
if (!commit || (commit->object.flags & TMP_MARK))
1392
return;
1393
commit->object.flags |= TMP_MARK;
1399
- ALLOC_GROW(tips->tip, tips->nr + 1, tips->alloc);
1400
- tips->tip[tips->nr++] = commit;
1394
+ commit_stack_push(tips, commit);
1395
}
1396
1397
static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***dst_tail)
@@ -1406,13 +1400,12 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1400
struct string_list src_tag = STRING_LIST_INIT_NODUP;
1401
struct string_list_item *item;
1402
struct ref *ref;
1409
- struct tips sent_tips;
1403
+ struct commit_stack sent_tips = COMMIT_STACK_INIT;
1404
1405
/*
1406
* Collect everything we know they would have at the end of
1407
* this push, and collect all tags they have.
1408
*/
1415
- memset(&sent_tips, 0, sizeof(sent_tips));
1409
for (ref = *dst; ref; ref = ref->next) {
1410
if (ref->peer_ref &&
1411
!is_null_oid(&ref->peer_ref->new_oid))
@@ -1422,7 +1415,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1415
if (starts_with(ref->name, "refs/tags/"))
1416
string_list_append(&dst_tag, ref->name);
1417
}
1425
- clear_commit_marks_many(sent_tips.nr, sent_tips.tip, TMP_MARK);
1418
+ clear_commit_marks_many(sent_tips.nr, sent_tips.items, TMP_MARK);
1419
1420
string_list_sort(&dst_tag);
1421
@@ -1471,7 +1464,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1464
src_commits[nr_src_commits++] = commit;
1465
}
1466
1474
- found_commits = get_reachable_subset(sent_tips.tip, sent_tips.nr,
1467
+ found_commits = get_reachable_subset(sent_tips.items,
1468
+ sent_tips.nr,
1469
src_commits, nr_src_commits,
1470
reachable_flag);
1471
@@ -1508,7 +1502,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1502
}
1503
1504
string_list_clear(&src_tag, 0);
1511
- free(sent_tips.tip);
1505
+ commit_stack_clear(&sent_tips);
1506
}
1507
1508
struct ref *find_ref_by_name(const struct ref *list, const char *name)