pub enum TemplateDir {
Unresolvable,
NoGit,
IsCheckout,
InsideCheckout,
Safe,
}Expand description
What may be done with a candidate template directory.
~/.config/git/git-templates is commonly a SYMLINK to a checkout of this
repository, in which case “installing” there means deleting and overwriting
TRACKED files.
Comparing the path against the source tree is NOT enough, and that is the mistake that caused both incidents: run the install from a git worktree and the two resolve to different paths — a different checkout of the same repo — so a path comparison says “not the source” and clobbers the main checkout. Asking git is the reliable test whatever route the symlink took.
Variants§
Unresolvable
The path does not exist and could not be created.
NoGit
No git to ask. Refuse rather than guess.
IsCheckout
It holds tracked files: it IS a checkout. Nothing to install — git init
already reads its templates from there, and the shims keep their
placeholder and resolve the binary at run time.
InsideCheckout
Inside a checkout but tracking nothing here. Still not ours to empty.
Safe
An ordinary directory. Safe to populate.
Trait Implementations§
Source§impl Clone for TemplateDir
impl Clone for TemplateDir
Source§fn clone(&self) -> TemplateDir
fn clone(&self) -> TemplateDir
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more