Skip to main content

Module template

Module template 

Source
Expand description

Worktree-store path-template rendering (spec §6).

New worktrees are placed according to a configurable template with the variables {repo_parent}, {repo}, {repo_root}, {branch}, {branch_slug}, and {home}. render substitutes them; ensure_outside_git rejects a rendered path that would land inside the .git directory.

Embedders must resolve worktree paths through this module. The template is repository configuration (Config::path_template), so it varies per repository and a user may change it at any time. Hard-coding DEFAULT_TEMPLATE’s layout — or any other guess at where a worktree lives — makes two tools that share a repository disagree about where its worktrees are. Workspace::create already renders through here and reports the resulting path, which is the easiest way to stay consistent.

Structs§

TemplateVars
The values substituted into a path template. For a bare repository these resolve against the bare repo’s own directory (spec §6).

Constants§

DEFAULT_TEMPLATE
The default worktree-store template (spec §6 “Sibling”).

Functions§

ensure_outside_git
Rejects a rendered worktree path that lies inside the repository’s .git directory (spec §6).
render
Renders template, substituting the TemplateVars. An unknown {var} or an unterminated { is a configuration error.