summaryrefslogtreecommitdiff
path: root/t/helper/test-reach.c
diff options
context:
space:
mode:
Diffstat (limited to 't/helper/test-reach.c')
-rw-r--r--t/helper/test-reach.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 995e382863..028ec00306 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -13,7 +13,6 @@
static void print_sorted_commit_ids(struct commit_list *list)
{
- int i;
struct string_list s = STRING_LIST_INIT_DUP;
while (list) {
@@ -23,7 +22,7 @@ static void print_sorted_commit_ids(struct commit_list *list)
string_list_sort(&s);
- for (i = 0; i < s.nr; i++)
+ for (size_t i = 0; i < s.nr; i++)
printf("%s\n", s.items[i].string);
string_list_clear(&s, 0);
@@ -36,7 +35,7 @@ int cmd__reach(int ac, const char **av)
struct commit_list *X, *Y;
struct object_array X_obj = OBJECT_ARRAY_INIT;
struct commit **X_array, **Y_array;
- int X_nr, X_alloc, Y_nr, Y_alloc;
+ size_t X_nr, X_alloc, Y_nr, Y_alloc;
struct strbuf buf = STRBUF_INIT;
struct repository *r = the_repository;
@@ -127,10 +126,12 @@ int cmd__reach(int ac, const char **av)
exit(128);
printf("%s(A,X):\n", av[1]);
print_sorted_commit_ids(list);
+ free_commit_list(list);
} else if (!strcmp(av[1], "reduce_heads")) {
struct commit_list *list = reduce_heads(X);
printf("%s(X):\n", av[1]);
print_sorted_commit_ids(list);
+ free_commit_list(list);
} else if (!strcmp(av[1], "can_all_from_reach")) {
printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1));
} else if (!strcmp(av[1], "can_all_from_reach_with_flag")) {
@@ -153,9 +154,10 @@ int cmd__reach(int ac, const char **av)
filter.with_commit_tag_algo = 0;
printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
+ clear_contains_cache(&cache);
} else if (!strcmp(av[1], "get_reachable_subset")) {
const int reachable_flag = 1;
- int i, count = 0;
+ int count = 0;
struct commit_list *current;
struct commit_list *list = get_reachable_subset(X_array, X_nr,
Y_array, Y_nr,
@@ -167,7 +169,7 @@ int cmd__reach(int ac, const char **av)
oid_to_hex(&list->item->object.oid));
count++;
}
- for (i = 0; i < Y_nr; i++) {
+ for (size_t i = 0; i < Y_nr; i++) {
if (Y_array[i]->object.flags & reachable_flag)
count--;
}
@@ -176,7 +178,14 @@ int cmd__reach(int ac, const char **av)
die(_("too many commits marked reachable"));
print_sorted_commit_ids(list);
+ free_commit_list(list);
}
+ object_array_clear(&X_obj);
+ strbuf_release(&buf);
+ free_commit_list(X);
+ free_commit_list(Y);
+ free(X_array);
+ free(Y_array);
return 0;
}