mirror of
https://github.com/git/git
synced 2024-10-02 14:45:21 +00:00
Merge branch 'jk/commit-graph-leak-fixes'
Leakfix. * jk/commit-graph-leak-fixes: commit-graph: clear oidset after finishing write commit-graph: free write-context base_graph_name during cleanup commit-graph: free write-context entries before overwriting commit-graph: free graph struct that was not added to chain commit-graph: delay base_graph assignment in add_graph_to_chain() commit-graph: free all elements of graph chain commit-graph: move slab-clearing to close_commit_graph() merge: free result of repo_get_merge_bases() commit-reach: free temporary list in get_octopus_merge_bases() t6700: mark test as leak-free
This commit is contained in:
commit
a45eddec40
|
@ -328,6 +328,7 @@ static int graph_write(int argc, const char **argv, const char *prefix)
|
|||
FREE_AND_NULL(options);
|
||||
string_list_clear(&pack_indexes, 0);
|
||||
strbuf_release(&buf);
|
||||
oidset_clear(&commits);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1632,6 +1632,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||
|
||||
for (j = remoteheads; j; j = j->next) {
|
||||
struct commit_list *common_one;
|
||||
struct commit *common_item;
|
||||
|
||||
/*
|
||||
* Here we *have* to calculate the individual
|
||||
|
@ -1641,7 +1642,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||
common_one = repo_get_merge_bases(the_repository,
|
||||
head_commit,
|
||||
j->item);
|
||||
if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
|
||||
common_item = common_one->item;
|
||||
free_commit_list(common_one);
|
||||
if (!oideq(&common_item->object.oid, &j->item->object.oid)) {
|
||||
up_to_date = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -523,8 +523,6 @@ static int add_graph_to_chain(struct commit_graph *g,
|
|||
cur_g = cur_g->base_graph;
|
||||
}
|
||||
|
||||
g->base_graph = chain;
|
||||
|
||||
if (chain) {
|
||||
if (unsigned_add_overflows(chain->num_commits,
|
||||
chain->num_commits_in_base)) {
|
||||
|
@ -535,6 +533,8 @@ static int add_graph_to_chain(struct commit_graph *g,
|
|||
g->num_commits_in_base = chain->num_commits + chain->num_commits_in_base;
|
||||
}
|
||||
|
||||
g->base_graph = chain;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -601,6 +601,8 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
|
|||
if (add_graph_to_chain(g, graph_chain, oids, i)) {
|
||||
graph_chain = g;
|
||||
valid = 1;
|
||||
} else {
|
||||
free_commit_graph(g);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -752,19 +754,10 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void close_commit_graph_one(struct commit_graph *g)
|
||||
{
|
||||
if (!g)
|
||||
return;
|
||||
|
||||
clear_commit_graph_data_slab(&commit_graph_data_slab);
|
||||
close_commit_graph_one(g->base_graph);
|
||||
free_commit_graph(g);
|
||||
}
|
||||
|
||||
void close_commit_graph(struct raw_object_store *o)
|
||||
{
|
||||
close_commit_graph_one(o->commit_graph);
|
||||
clear_commit_graph_data_slab(&commit_graph_data_slab);
|
||||
free_commit_graph(o->commit_graph);
|
||||
o->commit_graph = NULL;
|
||||
}
|
||||
|
||||
|
@ -2101,9 +2094,11 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
|
|||
free(graph_name);
|
||||
}
|
||||
|
||||
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
|
||||
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));
|
||||
final_graph_name = get_split_graph_filename(ctx->odb,
|
||||
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
|
||||
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);
|
||||
ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;
|
||||
|
||||
result = rename(ctx->graph_name, final_graph_name);
|
||||
|
@ -2552,6 +2547,7 @@ int write_commit_graph(struct object_directory *odb,
|
|||
|
||||
cleanup:
|
||||
free(ctx->graph_name);
|
||||
free(ctx->base_graph_name);
|
||||
free(ctx->commits.list);
|
||||
oid_array_clear(&ctx->oids);
|
||||
clear_topo_level_slab(&topo_levels);
|
||||
|
@ -2782,15 +2778,17 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
|
|||
|
||||
void free_commit_graph(struct commit_graph *g)
|
||||
{
|
||||
if (!g)
|
||||
return;
|
||||
if (g->data) {
|
||||
munmap((void *)g->data, g->data_len);
|
||||
g->data = NULL;
|
||||
while (g) {
|
||||
struct commit_graph *next = g->base_graph;
|
||||
|
||||
if (g->data)
|
||||
munmap((void *)g->data, g->data_len);
|
||||
free(g->filename);
|
||||
free(g->bloom_filter_settings);
|
||||
free(g);
|
||||
|
||||
g = next;
|
||||
}
|
||||
free(g->filename);
|
||||
free(g->bloom_filter_settings);
|
||||
free(g);
|
||||
}
|
||||
|
||||
void disable_commit_graph(struct repository *r)
|
||||
|
|
|
@ -173,6 +173,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
|
|||
for (k = bases; k; k = k->next)
|
||||
end = k;
|
||||
}
|
||||
free_commit_list(ret);
|
||||
ret = new_commits;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='git log --graph of skewed left octopus merge.'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-log-graph.sh
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='git log --graph of skewed merges'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-log-graph.sh
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='split commit graph'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
GIT_TEST_COMMIT_GRAPH=0
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='commit graph with 64-bit timestamps'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq TIME_IS_64BIT || ! test_have_prereq TIME_T_IS_64BIT
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='pull options'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='ancestor culling and limiting by parent number'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
check_revlist () {
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='recursive merge corner cases involving criss-cross merges'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-merge.sh
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='"git merge" top-level frontend'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
t3033_reset () {
|
||||
|
|
|
@ -8,6 +8,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-merge.sh
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='handling of deep trees in various commands'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
# We'll test against two depths here: a small one that will let us check the
|
||||
|
|
|
@ -4,6 +4,7 @@ test_description='git merge
|
|||
|
||||
Testing octopus merge with more than 25 refs.'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
@ -4,6 +4,7 @@ test_description='git merge
|
|||
|
||||
Testing octopus merge when reducing parents to independent branches.'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
# 0 - 1
|
||||
|
|
|
@ -4,6 +4,7 @@ test_description="Test that merge state is as expected after failed merge"
|
|||
|
||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'Ensure we restore original state if no merge strategy handles it' '
|
||||
|
|
|
@ -4,6 +4,7 @@ test_description='test auto-generated merge messages'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
check_oneline() {
|
||||
|
|
Loading…
Reference in a new issue