Skip to main content

Module shadow_skeleton

Module shadow_skeleton 

Source
Expand description

The entries of an empty bare repository, created in-process instead of by git init. What: The files and directories of an empty bare repository on the files ref backend, created in-process. Why: The shadow repository used to be made by git init --bare --template=, a Git start whose whole effect is these few entries; create_shadow_repository overwrites the config it writes and every later shadow step sets the HEAD it writes, so nothing else of Git’s work is used. Creating them here removes one process start from every commit (init; the config read that follows it is the wrapper’s own and stays). A torn creation leaves a directory that is not a repository; recovery removes the shadow tree as a whole (binary_recovery_tearing_shadow_tests.rs), exactly as it does for a torn git init.

In TS you’d write (pseudocode):

for (const directory of SKELETON_DIRECTORIES) await mkdir(join(shadow, directory), { recursive: true });
await writeFile(join(shadow, 'HEAD'), PLACEHOLDER_HEAD);

Constants§

PLACEHOLDER_HEAD
The HEAD a new repository starts with: a branch that does not exist yet. The shadow’s ref steps point HEAD at the transaction’s own target before any Git command reads it.
SKELETON_DIRECTORIES
Directories a bare repository has, relative to the repository, parents before children. The empty name is the repository directory itself.

Functions§

create_shadow_skeleton
What: Creates the directories and the HEAD of an empty bare repository on the files ref backend. Why: A directory another run of the same transaction already made is not an error, as with git init.