Skip to main content

Module outer_gitignore

Module outer_gitignore 

Source
Expand description

Shared helper: detect the enclosing git repo and append a path to its .gitignore.

Used by both memstead mem init (legacy disk-mem bootstrap) and memstead mem-repo init (post-cutover mem-repo-git bootstrap). The two commands differ in what path they ignore (mem root vs. the mem-repo/ directory) but share every other rule:

  • Walk upward from a starting directory looking for .git/.
  • Refuse to modify a .gitignore whose owning repo is $HOME — silent edits to dotfile repos are a recognized footgun.
  • Stop the walk at filesystem root and at mount-boundary crossings (the latter via metadata().dev() on unix; disabled elsewhere).
  • Append idempotently — if the ignore line is already present (modulo leading/trailing slash), no change is made.

Public surface: apply_outer_gitignore takes the start directory plus the path to ignore (which must be inside the outer repo for the relative computation to succeed); returns an OuterRepoOutcome the caller renders into a user-facing message.

Enums§

OuterRepoOutcome
Outcome of the outer-repo .gitignore handling step.

Functions§

apply_outer_gitignore
Walk upward from start looking for an outer .git/ directory; on success append ignore_path (rendered relative to the outer root) to that repo’s .gitignore. The starting directory is the parent of the new gitdir / mem-repo so we don’t rediscover our own git.