Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ At `42e5fca73`:
## Read, not measured

No check sees whether a commit a branch carries pins a `rust` commit the fork
holds. A worktree's build fetches its pin from the primary checkout's `rust/`
holds. A worktree's build takes its pin from the primary checkout's `rust/`
(`sysroot::fork_checkout`), never from the fork, so a commit made there and
never pushed builds green.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ worktree writes `core.worktree` into shared config and breaks git in the
primary checkout's `rust/`. The orchestrator measured that for
`git submodule update rust` in a linked worktree of the monorepo, which set the
primary's `.git/modules/rust/config` `core.worktree` to a path that does not
exist; this arm is the same command one level down and is unmeasured.
exist. One level down, under git 2.54.0, the same command has two outcomes,
measured on `sysroot`'s `two_pins` fixture shape (pull request #831). Run where
this arm runs it, in a fork checkout fresh from `git worktree add` whose
`library/backtrace` is an empty directory, it clones a git directory of the
checkout's own, under the primary's `.git/modules/rust/worktrees/<name>/modules/`,
leaves the primary's nested configuration unchanged, and `git status` in the
primary's `rust/` exits 0. Run where that `library/backtrace` is already a
`git worktree add` of the primary's nested repository, as `fork_checkout`
otherwise makes it, it rewrites the primary's nested `core.worktree` to the
linked path, and `git status` in the primary's `rust/` exits 128. Nothing
keeps the command from the second state: what it is safe in is a property of
the directory git happens to find, and the rule stands on the command.

`ensure_submodule` (`src/lib.rs`) runs `git submodule update --init
library/backtrace` in the same fork checkout, from `sysroot::build_std` and
Expand Down
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ pub fn ensure_submodules(repo_dir: &Path) {
/// the toolchain from them need. Refused in a linked worktree, whose `rust/` is
/// `sysroot::fork_checkout`'s to make: `git submodule` there rewrites the
/// `core.worktree` of the primary's fork.
///
/// One commit deep, where the primary's moves take the depth `.gitmodules`
/// declares, which for `rust` is its whole history: a linked worktree's fork
/// checkout shares the primary's objects and is told ahead of its pin from
/// behind it by ancestry, and a runner has no linked worktree.
pub fn ensure_shallow_fork(root: &Path) -> Result<(), String> {
if root.join("rust/x.py").exists() {
return Ok(());
Expand All @@ -131,12 +136,8 @@ pub fn ensure_shallow_fork(root: &Path) -> Result<(), String> {
root.join("rust").display()
));
}
let status = Command::new("git")
.args(["submodule", "update", "--init", "--depth", "1", "rust"])
.current_dir(root)
.status()
.map_err(|e| format!("git submodule update --init --depth 1 rust: {e}"))?;
status.success().then_some(()).ok_or_else(|| format!("git submodule update --init --depth 1 rust exited {status}"))
sysroot::submodule_update(root, "rust", true);
Ok(())
}

/// Ensure a single git submodule is checked out.
Expand Down
Loading
Loading