]> git.feebdaed.xyz Git - 0xmirror/git.git/commit
odb: refactor `odb_clear()` to `odb_free()`
authorPatrick Steinhardt <ps@pks.im>
Wed, 19 Nov 2025 07:50:52 +0000 (08:50 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Nov 2025 01:41:03 +0000 (17:41 -0800)
commitf8bdf3127ab7df8a8f3039f41889b35eefe029a3
treebe8a4800d6630b6d0f3de2d4f17fa5bac8b7ffc8
parent9aaba579932781c74f67d6cecddaad59f0daaaef
odb: refactor `odb_clear()` to `odb_free()`

The function `odb_clear()` releases all resources allocated to an object
database and ensures that all fields become zero'd out. Despite its
naming though it doesn't really clear the object database so that it
becomes ready for reuse afterwards again -- the caller would first have
to reinitialize it, and that contradicts the terminology of "clearing"
as we have defined it in our coding guidelines.

There isn't really only a reason to have "clearing" semantics, either.
There's only a single caller of `odb_clear()`, and that caller also ends
up freeing the object database structure itself.

Refactor the function to have "freeing" semantics instead, so that the
structure itself is also freed, which allows us to drop some useless
boilerplate to zero out the structure's members.

This refactoring reveals that we're trying to close the commit graph
multiple times: once directly via `free_commit_graph()`, and once via
`odb_close()`. Drop the former call.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb.c
odb.h
repository.c