diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-01-15 07:12:40 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-01-15 07:12:41 -0800 |
| commit | 24c43fb10b7d8fb668740f28b107f9ecb73a268d (patch) | |
| tree | abcf709ab9449bab6d23903ebd988b9cc59c0a45 | |
| parent | c0453835ab4d507a48d536f8a6352ef03bcbd464 (diff) | |
| parent | 3d099686560b848fefe71b7e8edf70d1674b9c73 (diff) | |
| download | git-24c43fb10b7d8fb668740f28b107f9ecb73a268d.tar.xz | |
Merge branch 'ps/odb-misc-fixes'
Miscellaneous fixes on object database layer.
* ps/odb-misc-fixes:
odb: properly close sources before freeing them
builtin/gc: fix condition for whether to write commit graphs
| -rw-r--r-- | builtin/gc.c | 8 | ||||
| -rw-r--r-- | odb.c | 2 | ||||
| -rwxr-xr-x | t/t7900-maintenance.sh | 25 |
3 files changed, 31 insertions, 4 deletions
diff --git a/builtin/gc.c b/builtin/gc.c index 92c6e7b954..17ff68cbd9 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -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); } } @@ -1117,13 +1117,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); diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 6b36f52df7..7cc0ce57f8 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -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 && + test_commit initial && + git switch --create feature && + test_commit feature-1 && + test_commit feature-2 && + git switch - && + test_commit main-1 && + test_commit main-2 && + git merge feature && + + # We have 6 commits, 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 |
