mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-27 13:21:17 -05:00
The Git project is not exactly the easiest project to get started in: it's written in C and POSIX shell, with bits of Perl, Rust and other languages sprinkled into it. On top of that, the project has grown somewhat organically over time, making the codebase hard to navigate. These are problems that we're aware of, and there have been and still are efforts to clean up some of the technical debt that is natural to exist an a project that is more than 20 years old. Furthermore, we provide resources to newcomers that help them out like our coding guidelines, code of conduct or "MyFirstContribution.adoc". But there is a rather practical problem: finding your way around in our project's tree is not easy. Doing a directory listing in the top-level directory will present you with more than 550 files, which makes it extremely hard for a newcomer to figure out what files they are even supposed to look at. This makes the onboarding experience somewhat harder than it really needs to be. This isn't only a problem for newcomers though, as I myself struggle to find the files I am looking for because of the sheer number of files. Besides the problem of discoverability it also creates a problem of structure. It is not obvious at all which files are part of "libgit.a" and which files are only linked into our final executables. So while we have this split in our build systems, that split is not evident at all in our tree. Introduce a new "lib/" directory and move all of our sources for "libgit.a" into it to fix these issues. It makes the split we have evident and reduces the number of files in our top-level tree from 550 files to ~80 files. This is still a lot of files, but it's significantly easier to navigate already. Furthermore, we can further iterate after this step and think about introducing a better structure for remaining files, as well. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
72 lines
2.2 KiB
C
72 lines
2.2 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 child_process child = CHILD_PROCESS_INIT;
|
|
* struct tmp_objdir *t = tmp_objdir_create(repo, "incoming");
|
|
* strvec_push(&child.args, cmd);
|
|
* strvec_pushv(&child.env, tmp_objdir_env(t));
|
|
* if (!run_command(&child)) && !tmp_objdir_migrate(t))
|
|
* printf("success!\n");
|
|
* else
|
|
* die("failed...tmp_objdir will clean up for us");
|
|
*
|
|
*/
|
|
|
|
struct repository;
|
|
struct tmp_objdir;
|
|
|
|
/*
|
|
* Create a new temporary object directory with the specified prefix;
|
|
* returns NULL on failure.
|
|
*/
|
|
struct tmp_objdir *tmp_objdir_create(struct repository *r, const char *prefix);
|
|
|
|
/*
|
|
* 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 *);
|
|
|
|
/*
|
|
* Remove all objects from the temporary object directory, while leaving it
|
|
* around so more objects can be added.
|
|
*/
|
|
void tmp_objdir_discard_objects(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 *);
|
|
|
|
/*
|
|
* Replaces the writable object store in the current process with the temporary
|
|
* object directory and makes the former main object store an alternate.
|
|
* If will_destroy is nonzero, the object directory may not be migrated.
|
|
*/
|
|
void tmp_objdir_replace_primary_odb(struct tmp_objdir *, int will_destroy);
|
|
|
|
#endif /* TMP_OBJDIR_H */
|