From c92108a11c107aaca8694bbb4b8e6bc9d5e3fd2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?m=C3=BCde?= Date: Sat, 16 May 2026 02:58:34 +0200 Subject: [PATCH] lifecycle: fetch into checked-out main with --update-head-ok MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setup_applied does `git init --initial-branch=main` then `git fetch main:refs/heads/main` to seed the applied repo with proposed's initial commit. git's default safeguard refuses to fetch into the currently-checked-out branch, even though the working tree is empty (we just init'd). add --update-head-ok to bypass — the read-tree-reset immediately after fetches the right state, so the safeguard the flag bypasses isn't relevant here anyway. repro from the user: spawn of 'dmatrix' failed with fatal: refusing to fetch into branch 'refs/heads/main' checked out at '/var/lib/hyperhive/applied/dmatrix' --- hive-c0re/src/lifecycle.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hive-c0re/src/lifecycle.rs b/hive-c0re/src/lifecycle.rs index b3395db..5958081 100644 --- a/hive-c0re/src/lifecycle.rs +++ b/hive-c0re/src/lifecycle.rs @@ -428,7 +428,18 @@ pub async fn setup_applied( let proposed_str = proposed.display().to_string(); git( applied_dir, - &["fetch", "--no-tags", &proposed_str, "main:refs/heads/main"], + // --update-head-ok lets us fetch into refs/heads/main while + // HEAD still points there. git's default safeguard refuses + // to avoid index/working-tree desync, but the working tree + // is empty (we just `init`'d) and we read-tree-reset right + // after, so the safeguard is moot here. + &[ + "fetch", + "--no-tags", + "--update-head-ok", + &proposed_str, + "main:refs/heads/main", + ], ) .await?; git_read_tree_reset(applied_dir, "refs/heads/main").await?;