remote: use commit_stack for src_commits
Use commit_stack instead of open-coding it. 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
bb3a1ce91f964b353e8a428be574c20571db60a6
1 file changed
+7
-8
remote.c
+7
-8
@@ -1443,9 +1443,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1443
if (sent_tips.nr) {
1444
const int reachable_flag = 1;
1445
struct commit_list *found_commits;
1446
- struct commit **src_commits;
1447
- size_t nr_src_commits = 0, alloc_src_commits = 16;
1448
- ALLOC_ARRAY(src_commits, alloc_src_commits);
1446
+ struct commit_stack src_commits = COMMIT_STACK_INIT;
1447
1448
for_each_string_list_item(item, &src_tag) {
1449
struct ref *ref = item->util;
@@ -1460,13 +1458,13 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1458
/* not pushing a commit, which is not an error */
1459
continue;
1460
1463
- ALLOC_GROW(src_commits, nr_src_commits + 1, alloc_src_commits);
1464
- src_commits[nr_src_commits++] = commit;
1461
+ commit_stack_push(&src_commits, commit);
1462
}
1463
1464
found_commits = get_reachable_subset(sent_tips.items,
1465
sent_tips.nr,
1469
- src_commits, nr_src_commits,
1466
+ src_commits.items,
1467
+ src_commits.nr,
1468
reachable_flag);
1469
1470
for_each_string_list_item(item, &src_tag) {
@@ -1496,8 +1494,9 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1494
dst_ref->peer_ref = copy_ref(ref);
1495
}
1496
1499
- clear_commit_marks_many(nr_src_commits, src_commits, reachable_flag);
1500
- free(src_commits);
1497
+ clear_commit_marks_many(src_commits.nr, src_commits.items,
1498
+ reachable_flag);
1499
+ commit_stack_clear(&src_commits);
1500
free_commit_list(found_commits);
1501
}
1502