Skip to content

Commit 81ffbf8

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab1f692 commit 81ffbf8

File tree

8 files changed

+32
-1
lines changed

8 files changed

+32
-1
lines changed

reflog-walk.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
struct complete_reflogs {
1010
char *ref;
11-
const char *short_ref;
11+
char *short_ref;
1212
struct reflog_info {
1313
struct object_id ooid, noid;
1414
char *email;
@@ -51,9 +51,16 @@ static void free_complete_reflog(struct complete_reflogs *array)
5151
}
5252
free(array->items);
5353
free(array->ref);
54+
free(array->short_ref);
5455
free(array);
5556
}
5657

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+
5764
static struct complete_reflogs *read_complete_reflog(const char *ref)
5865
{
5966
struct complete_reflogs *reflogs =
@@ -116,6 +123,21 @@ void init_reflog_walk(struct reflog_walk_info **info)
116123
(*info)->complete_reflogs.strdup_strings = 1;
117124
}
118125

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+
119141
int add_reflog_for_walk(struct reflog_walk_info *info,
120142
struct commit *commit, const char *name)
121143
{

reflog-walk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ struct reflog_walk_info;
88
struct date_mode;
99

1010
void init_reflog_walk(struct reflog_walk_info **info);
11+
void reflog_walk_info_release(struct reflog_walk_info *info);
1112
int add_reflog_for_walk(struct reflog_walk_info *info,
1213
struct commit *commit, const char *name);
1314
void show_reflog_message(struct reflog_walk_info *info, int,

revision.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,7 @@ void release_revisions(struct rev_info *revs)
29532953
clear_pathspec(&revs->prune_data);
29542954
release_revisions_mailmap(revs->mailmap);
29552955
free_grep_patterns(&revs->grep_filter);
2956+
reflog_walk_info_release(revs->reflog_info);
29562957
}
29572958

29582959
static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)

t/t0100-previous.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='previous branch syntax @{-n}'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
test_expect_success 'branch -d @{-1}' '

t/t1401-symbolic-ref.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='basic symbolic-ref tests'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
# If the tests munging HEAD fail, they can break detection of

t/t1411-reflog-show.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='Test reflog display routines'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
test_expect_success 'setup' '

t/t1412-reflog-loop.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='reflog walk shows repeated commits again'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup commits' '

t/t1415-worktree-refs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='per-worktree refs'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success 'setup' '

0 commit comments

Comments
 (0)