tmp-objdir: new API for creating temporary writable databases

The tmp_objdir API provides the ability to create temporary object
directories, but was designed with the goal of having subprocesses
access these object stores, followed by the main process migrating
objects from it to the main object store or just deleting it.  The
subprocesses would view it as their primary datastore and write to it.

Here we add the tmp_objdir_replace_primary_odb function that replaces
the current process's writable "main" object directory with the
specified one. The previous main object directory is restored in either
tmp_objdir_migrate or tmp_objdir_destroy.

For the --remerge-diff usecase, add a new `will_destroy` flag in `struct
object_database` to mark ephemeral object databases that do not require
fsync durability.

Add 'git prune' support for removing temporary object databases, and
make sure that they have a name starting with tmp_ and containing an
operation-specific name.

Based-on-patch-by: Elijah Newren <newren@gmail.com>

Signed-off-by: Neeraj Singh <neerajsi@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Neeraj Singh
2021-12-06 22:05:04 +00:00
committed by Junio C Hamano
parent cefe983a32
commit b3cecf49ea
8 changed files with 162 additions and 14 deletions

View File

@ -513,7 +513,7 @@ struct raw_object_store *raw_object_store_new(void)
return o;
}
static void free_object_directory(struct object_directory *odb)
void free_object_directory(struct object_directory *odb)
{
free(odb->path);
odb_clear_loose_cache(odb);