mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Merge branch 'ps/odb-misc-fixes' into jch
Miscellaneous fixes on object database layer. Comments? * ps/odb-misc-fixes: odb: properly close sources before freeing them builtin/gc: fix condition for whether to write commit graphs
This commit is contained in:
@@ -1130,8 +1130,10 @@ static int dfs_on_ref(const struct reference *ref, void *cb_data)
|
||||
return 0;
|
||||
|
||||
commit = lookup_commit(the_repository, maybe_peeled);
|
||||
if (!commit)
|
||||
if (!commit || commit->object.flags & SEEN)
|
||||
return 0;
|
||||
commit->object.flags |= SEEN;
|
||||
|
||||
if (repo_parse_commit(the_repository, commit) ||
|
||||
commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
|
||||
return 0;
|
||||
@@ -1141,7 +1143,7 @@ static int dfs_on_ref(const struct reference *ref, void *cb_data)
|
||||
if (data->num_not_in_graph >= data->limit)
|
||||
return 1;
|
||||
|
||||
commit_list_append(commit, &stack);
|
||||
commit_list_insert(commit, &stack);
|
||||
|
||||
while (!result && stack) {
|
||||
struct commit_list *parent;
|
||||
@@ -1162,7 +1164,7 @@ static int dfs_on_ref(const struct reference *ref, void *cb_data)
|
||||
break;
|
||||
}
|
||||
|
||||
commit_list_append(parent->item, &stack);
|
||||
commit_list_insert(parent->item, &stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
odb.c
2
odb.c
@@ -1120,13 +1120,13 @@ void odb_free(struct object_database *o)
|
||||
oidmap_clear(&o->replace_map, 1);
|
||||
pthread_mutex_destroy(&o->replace_mutex);
|
||||
|
||||
odb_close(o);
|
||||
odb_free_sources(o);
|
||||
|
||||
for (size_t i = 0; i < o->cached_object_nr; i++)
|
||||
free((char *) o->cached_objects[i].value.buf);
|
||||
free(o->cached_objects);
|
||||
|
||||
odb_close(o);
|
||||
packfile_store_free(o->packfiles);
|
||||
string_list_clear(&o->submodule_source_paths, 0);
|
||||
|
||||
|
||||
@@ -206,6 +206,31 @@ test_expect_success 'commit-graph auto condition' '
|
||||
test_subcommand $COMMIT_GRAPH_WRITE <cg-two-satisfied.txt
|
||||
'
|
||||
|
||||
test_expect_success 'commit-graph auto condition with merges' '
|
||||
test_when_finished "rm -rf repo" &&
|
||||
git init repo &&
|
||||
(
|
||||
cd repo &&
|
||||
git config set maintenance.auto false &&
|
||||
git commit --allow-empty -m initial &&
|
||||
git switch --create feature &&
|
||||
git commit --allow-empty -m feature-1 &&
|
||||
git commit --allow-empty -m feature-2 &&
|
||||
git switch - &&
|
||||
git commit --allow-empty -m main-1 &&
|
||||
git commit --allow-empty -m main-2 &&
|
||||
git merge feature &&
|
||||
|
||||
# We have 6 commit, none of which are covered by a commit
|
||||
# graph. So this must be the boundary at which we start to
|
||||
# perform maintenance.
|
||||
test_must_fail git -c maintenance.commit-graph.auto=7 \
|
||||
maintenance is-needed --auto --task=commit-graph &&
|
||||
git -c maintenance.commit-graph.auto=6 \
|
||||
maintenance is-needed --auto --task=commit-graph
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'run --task=bogus' '
|
||||
test_must_fail git maintenance run --task=bogus 2>err &&
|
||||
test_grep "is not a valid task" err
|
||||
|
||||
Reference in New Issue
Block a user