From 5df6e41e05b9449a964467bc11a9d7fce2d802ec Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 00:26:36 +0000 Subject: populate: skip symlink and git sources with nothing to do Each command on a remote target costs about three round trips, so the bench's 30 symlink and 20 git sources took about 4.5 of a no-op run's 7.2 s with 30 ms to the target, with one command each. The command after taking the lock that lists file sources, now the probe (probe.rs), also finds out what's at the target paths of symlink sources, the symlink, if any, and of git sources with a commit as ref and without fetchAlways: if git_problems finds nothing wrong with the work tree, which keeps guarding every Git command, its HEAD, its origin's URL, and what git status --ignored and git submodule status print. A symlink source whose symlink points to the target already runs nothing. So does a git source whose work tree has the commit checked out, the source's URL, nothing modified, untracked, or ignored, and its submodules at their commits; the flakes step takes it for checked, as after the git script. Not where the flakes step rewrites a lock file in place. The scenario symlink-git-skip checks that an unchanged symlink stays the same file, which ln would replace, and that a symlink pointing elsewhere, a modified file, an untracked one, and another commit make them deliver again. --- pkgs/populate/tests/scenarios.nix | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'pkgs/populate/tests') diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix index 96804f8..f7ece9a 100644 --- a/pkgs/populate/tests/scenarios.nix +++ b/pkgs/populate/tests/scenarios.nix @@ -1172,6 +1172,51 @@ in } ]; })) + # Symlink and git sources with nothing to do get skipped: the symlink + # stays the same file, which ln would replace. A symlink pointing + # elsewhere, and a modified file, an untracked one, and another commit + # in the work tree make them deliver again. + (s "symlink-git-skip" (let + sources = { + l.symlink = "g"; + g.git = { url = gitUrl; ref = gitHead; }; + }; + delivered = '' + expect_eq l "$(readlink "$T"/l)" g + expect_eq HEAD "$(git -C "$T"/g rev-parse HEAD)" ${gitHead} + expect_eq status "$(git -C "$T"/g status --porcelain --ignored)" "" + ''; + in { + phases = [ + { + inherit sources; + check = delivered; + mutate = '' + stat -c %i "$T"/l > "$T"/inode + ''; + } + # Nothing to do, so the symlink stays. + { + inherit sources; + check = delivered + '' + expect_eq inode "$(stat -c %i "$T"/l)" "$(cat "$T"/inode)" + ''; + mutate = '' + ln -sfn elsewhere "$T"/l + echo modified >> "$T"/g/flake.nix + echo new > "$T"/g/new + ''; + } + { + inherit sources; + check = delivered; + mutate = '' + git -C "$T"/g -c user.name=x -c user.email=x commit -q --allow-empty -m other + ''; + } + { inherit sources; check = delivered; } + ]; + })) (s "cycle" { phases = [{ sources = { -- cgit v1.3.1 [cgit] Unable to lock slot /tmp/cgit/b0100000.lock: Permission denied (13)