From c93dcff0741d5cdc4b3bb0aa3c44e88203e6573e Mon Sep 17 00:00:00 2001 From: damocles Date: Mon, 24 Aug 2026 13:09:31 +0200 Subject: [PATCH] knowledge: reset local tree before pulling to avoid ff-only wedge --- hive-c0re/src/workers/knowledge.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hive-c0re/src/workers/knowledge.rs b/hive-c0re/src/workers/knowledge.rs index c2e36079..33b07d7e 100644 --- a/hive-c0re/src/workers/knowledge.rs +++ b/hive-c0re/src/workers/knowledge.rs @@ -254,6 +254,21 @@ pub async fn pull(coord: &Coordinator) -> Result<()> { .args(["-C", LOCAL_DIR, "remote", "set-url", "origin", &plain]) .output() .await; + // Discard any local modifications before pulling. Nothing in this + // codebase writes to `LOCAL_DIR` after the initial clone (`seed_readme` + // runs once, at creation, before any pull) — this working tree exists + // to mirror `origin/main`, not to be edited in place. A tracked file + // left dirty by any other means (a stray manual edit on the host, an + // interrupted prior operation) would otherwise abort the `--ff-only` + // merge below with "local changes would be overwritten", wedging + // every future pull the same way until someone notices and resets it + // by hand. Best-effort: a reset failure surfaces through the pull's + // own error below rather than needing its own branch here. + let _ = crate::lifecycle::git_command() + .args(["-C", LOCAL_DIR, "reset", "--hard", "HEAD"]) + .output() + .await; + let before = head_sha().await; // The repo is public (`ensure_knowledge_repo` makes it so), so an // unauthenticated pull is enough — but authenticate when a token is around,