revisions API: release "reflog_info" in release revisions()

Add a missing reflog_walk_info_release() to "reflog-walk.c" and use it in release_revisions(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Apr 13, 2022 at 22:01 UTC 81ffbf838070bf68970688e4a11399f58c562cce
8 files changed +32 -1
reflog-walk.c
+23 -1
@@ -8,7 +8,7 @@
8
9 struct complete_reflogs {
10 char *ref;
11 - const char *short_ref;
11 + char *short_ref;
12 struct reflog_info {
13 struct object_id ooid, noid;
14 char *email;
@@ -51,9 +51,16 @@ static void free_complete_reflog(struct complete_reflogs *array)
51 }
52 free(array->items);
53 free(array->ref);
54 + free(array->short_ref);
55 free(array);
56 }
57
58 +static void complete_reflogs_clear(void *util, const char *str)
59 +{
60 + struct complete_reflogs *array = util;
61 + free_complete_reflog(array);
62 +}
63 +
64 static struct complete_reflogs *read_complete_reflog(const char *ref)
65 {
66 struct complete_reflogs *reflogs =
@@ -116,6 +123,21 @@ void init_reflog_walk(struct reflog_walk_info **info)
123 (*info)->complete_reflogs.strdup_strings = 1;
124 }
125
126 +void reflog_walk_info_release(struct reflog_walk_info *info)
127 +{
128 + size_t i;
129 +
130 + if (!info)
131 + return;
132 +
133 + for (i = 0; i < info->nr; i++)
134 + free(info->logs[i]);
135 + string_list_clear_func(&info->complete_reflogs,
136 + complete_reflogs_clear);
137 + free(info->logs);
138 + free(info);
139 +}
140 +
141 int add_reflog_for_walk(struct reflog_walk_info *info,
142 struct commit *commit, const char *name)
143 {
reflog-walk.h
+1
@@ -8,6 +8,7 @@ struct reflog_walk_info;
8 struct date_mode;
9
10 void init_reflog_walk(struct reflog_walk_info **info);
11 +void reflog_walk_info_release(struct reflog_walk_info *info);
12 int add_reflog_for_walk(struct reflog_walk_info *info,
13 struct commit *commit, const char *name);
14 void show_reflog_message(struct reflog_walk_info *info, int,
revision.c
+1
@@ -2953,6 +2953,7 @@ void release_revisions(struct rev_info *revs)
2953 clear_pathspec(&revs->prune_data);
2954 release_revisions_mailmap(revs->mailmap);
2955 free_grep_patterns(&revs->grep_filter);
2956 + reflog_walk_info_release(revs->reflog_info);
2957 }
2958
2959 static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
t/t0100-previous.sh
+1
@@ -5,6 +5,7 @@ test_description='previous branch syntax @{-n}'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success 'branch -d @{-1}' '
t/t1401-symbolic-ref.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='basic symbolic-ref tests'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 # If the tests munging HEAD fail, they can break detection of
t/t1411-reflog-show.sh
+1
@@ -4,6 +4,7 @@ test_description='Test reflog display routines'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7 +TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9
10 test_expect_success 'setup' '
t/t1412-reflog-loop.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='reflog walk shows repeated commits again'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'setup commits' '
t/t1415-worktree-refs.sh
+1
@@ -2,6 +2,7 @@
2
3 test_description='per-worktree refs'
4
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'setup' '