File: tmp-objdir.h

package info (click to toggle)
git 1:2.20.1-2+deb10u3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,676 kB
  • sloc: ansic: 210,769; sh: 180,432; perl: 29,102; tcl: 21,663; python: 6,143; makefile: 3,700; sed: 189; php: 120; asm: 98; csh: 45; ruby: 24; lisp: 12
file content (54 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#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 */