mirror of
https://github.com/git-for-windows/git.git
synced 2026-03-26 22:24:27 -05:00
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
#ifndef TMP_OBJDIR_H
|
|
#define TMP_OBJDIR_H
|
|
|
|
/*
|
|
* This API allows you to create a temporary object directory, advertise it to
|
|
* sub-processes via GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES,
|
|
* and then either migrate its object into the main object directory, or remove
|
|
* it. The library handles unexpected signal/exit death by cleaning up the
|
|
* temporary directory.
|
|
*
|
|
* Example:
|
|
*
|
|
* struct tmp_objdir *t = tmp_objdir_create();
|
|
* if (!run_command_v_opt_cd_env(cmd, 0, NULL, tmp_objdir_env(t)) &&
|
|
* !tmp_objdir_migrate(t))
|
|
* printf("success!\n");
|
|
* else
|
|
* die("failed...tmp_objdir will clean up for us");
|
|
*
|
|
*/
|
|
|
|
struct tmp_objdir;
|
|
|
|
/*
|
|
* Create a new temporary object directory; returns NULL on failure.
|
|
*/
|
|
struct tmp_objdir *tmp_objdir_create(void);
|
|
|
|
/*
|
|
* Return a list of environment strings, suitable for use with
|
|
* child_process.env, that can be passed to child programs to make use of the
|
|
* temporary object directory.
|
|
*/
|
|
const char **tmp_objdir_env(const struct tmp_objdir *);
|
|
|
|
/*
|
|
* Finalize a temporary object directory by migrating its objects into the main
|
|
* object database, removing the temporary directory, and freeing any
|
|
* associated resources.
|
|
*/
|
|
int tmp_objdir_migrate(struct tmp_objdir *);
|
|
|
|
/*
|
|
* Destroy a temporary object directory, discarding any objects it contains.
|
|
*/
|
|
int tmp_objdir_destroy(struct tmp_objdir *);
|
|
|
|
/*
|
|
* Add the temporary object directory as an alternate object store in the
|
|
* current process.
|
|
*/
|
|
void tmp_objdir_add_as_alternate(const struct tmp_objdir *);
|
|
|
|
#endif /* TMP_OBJDIR_H */
|