diff options
author | Neeraj Singh <neerajsi@microsoft.com> | 2021-12-06 23:05:04 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-08 23:06:36 +0100 |
commit | b3cecf49eac00d62e361bf6e6e81392f5a2fb571 (patch) | |
tree | ae4937eebd6d08bb828dd1967d043369c496c945 /object-store.h | |
parent | The ninth batch (diff) | |
download | git-b3cecf49eac00d62e361bf6e6e81392f5a2fb571.tar.xz git-b3cecf49eac00d62e361bf6e6e81392f5a2fb571.zip |
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>
Diffstat (limited to 'object-store.h')
-rw-r--r-- | object-store.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/object-store.h b/object-store.h index c5130d8bae..74b1b5872a 100644 --- a/object-store.h +++ b/object-store.h @@ -28,6 +28,11 @@ struct object_directory { struct oidtree *loose_objects_cache; /* + * This object store is ephemeral, so there is no need to fsync. + */ + int will_destroy; + + /* * Path to the alternative object store. If this is a relative path, * it is relative to the current working directory. */ @@ -59,6 +64,17 @@ void add_to_alternates_file(const char *dir); void add_to_alternates_memory(const char *dir); /* + * Replace the current writable object directory with the specified temporary + * object directory; returns the former primary object directory. + */ +struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy); + +/* + * Restore a previous ODB replaced by set_temporary_main_odb. + */ +void restore_primary_odb(struct object_directory *restore_odb, const char *old_path); + +/* * Populate and return the loose object cache array corresponding to the * given object ID. */ @@ -68,6 +84,9 @@ struct oidtree *odb_loose_cache(struct object_directory *odb, /* Empty the loose object cache for the specified object directory. */ void odb_clear_loose_cache(struct object_directory *odb); +/* Clear and free the specified object directory */ +void free_object_directory(struct object_directory *odb); + struct packed_git { struct hashmap_entry packmap_ent; struct packed_git *next; |