aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-13 03:41:54 +0000
committertv <tv@krebsco.de>2026-11-13 03:41:54 +0000
commit4ee857a9f1c9153b944a2f48a89f35d9657b2ca5 (patch)
tree039561c3e3c39faf1670ad05b11c600468b3817c /lib
parent3219e04ce4ff01b5f013e89d6245af9d28d73814 (diff)
populate git: refuse work trees whose .git names places elsewhere
A .git directory names places elsewhere in more ways than being a symlink or a file: core.worktree, symlinks to a configuration, to objects, or to refs elsewhere, a commondir file naming another repository, and linked work trees. Git's commands follow them, so fetching, resetting, setting the remote's URL, and cleaning change what is elsewhere: with core.worktree, git clean removes everything in the work tree it names. And Git runs commands the configuration names, like core.fsmonitor, and hooks. Populate only uses a work tree whose .git directory has no symlinks, no commondir file, no linked work trees, and only configuration that git clone and populate write, where submodules' repositories may have their work tree in the work tree. Otherwise populating fails with an error telling what's wrong, unless the new option reclone replaces the work tree by a fresh clone. Git runs without hooks and without fsmonitor in any case. The work tree also gets reset to the commit if HEAD is there already: a lock file rewritten in place, or created and staged by Nix, stays otherwise once the source stops drawing inputs. A safety scenario refuses work trees with core.worktree, a symlinked configuration, a commondir file, and core.fsmonitor, replaces them with reclone, and checks that a hook doesn't run. A git scenario stops drawing inputs and checks that the work tree is clean.
Diffstat (limited to 'lib')
-rw-r--r--lib/types/populate.nix4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/types/populate.nix b/lib/types/populate.nix
index 1a18b62..56b0292 100644
--- a/lib/types/populate.nix
+++ b/lib/types/populate.nix
@@ -258,6 +258,10 @@
ref = lib.mkOption {
type = lib.types.str; # TODO lib.types.git.ref
};
+ reclone = lib.mkOption {
+ default = false;
+ type = lib.types.bool;
+ };
rewriteLock = lib.mkOption {
default = true;
type = lib.types.bool;