From 06f3ddfd3a32e9038ea36c6e196d71adf1753391 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 14 Nov 2026 02:07:45 +0000 Subject: populate: check each Git work tree once per run git_problems looks through all of a work tree for .git files and directories, which takes long for big ones like nixpkgs. A git source drawn from by a flake-input source got checked three times per run: when delivering it, by resolve, deciding on git+file:, and by derived_state, for the key. populate notes the work trees git_problems found nothing wrong with during the run, and resolve and derived_state get told, so git_flake only checks the rest, e.g. hooks. The git source's script prints checked if it checked the work tree that was there, instead of making a fresh clone. Its commands print to standard error, without getting the standard output populate reads, so nothing they leave running keeps populate waiting. rewrite-cache-gitsource is rewrite-cache-git with a git source. --- pkgs/populate/src/run.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'pkgs/populate/src/run.rs') diff --git a/pkgs/populate/src/run.rs b/pkgs/populate/src/run.rs index c9bd9fb..7fd73f7 100644 --- a/pkgs/populate/src/run.rs +++ b/pkgs/populate/src/run.rs @@ -107,6 +107,10 @@ pub struct Context { /// What nix flake metadata prints for flakes, by reference, so it's /// obtained only once, even if several sources use the same flake. metadata: std::cell::RefCell>, + /// The paths of Git work trees on the target that git_problems found + /// nothing wrong with during this run, so finding that out, which + /// takes looking through all of the work tree, happens only once. + git_checked: std::cell::RefCell>, } impl Context { @@ -132,6 +136,7 @@ impl Context { ssh, ssh_nix, metadata: Default::default(), + git_checked: Default::default(), }; context.write_ssh(&context.ssh, &context.ssh_options(true))?; context.write_ssh(&context.ssh_nix, &context.ssh_options(false))?; @@ -255,6 +260,18 @@ impl Context { Ok(metadata) } + /// Notes that git_problems found nothing wrong with the Git work tree + /// at path on the target. + pub fn git_checked(&self, path: &str) { + self.git_checked.borrow_mut().insert(path.to_string()); + } + + /// Whether git_problems found nothing wrong with the Git work tree at + /// path on the target during this run. + pub fn is_git_checked(&self, path: &str) -> bool { + self.git_checked.borrow().contains(path) + } + /// Runs shell code on the target, returning its output. pub fn output(&self, script: &str, args: &[&str]) -> Result { output(&mut self.shell(script, args)) -- cgit v1.3.1