From 46f0540515185963b8412ed98e9b6ba73f00b151 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 4 Aug 2026 04:48:26 +0000 Subject: [PATCH] Report git's stderr when a merge fails without leaving conflicts --- scripts/unsloth/repin.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/unsloth/repin.py b/scripts/unsloth/repin.py index aae02356d34..ac9028592ee 100644 --- a/scripts/unsloth/repin.py +++ b/scripts/unsloth/repin.py @@ -150,10 +150,18 @@ def repin_one(pin: dict, base: str, work: Path) -> dict: res = json.loads(report.read_text()) if report.exists() else {} if rc != 0: out["action"] = "conflict" - out["files"] = [x["file"] for x in res.get("refused", [])] - out["note"] = "; ".join( - f"`{x['file']}`: {x['reason']}" for x in res.get("refused", []) - ) or "merge conflicted" + refused = res.get("refused", []) + out["files"] = [x["file"] for x in refused if x["file"] != "-"] + if out["files"]: + out["note"] = "; ".join(f"`{x['file']}`: {x['reason']}" for x in refused) + else: + # git refused the merge without leaving a single conflicted + # file, so the conflict report explains nothing. Its stderr is + # the only thing that does, and discarding it turns a + # diagnosable failure into "no conflicted files". + tail = ((m.stderr or "") + (m.stdout or "")).strip().splitlines() + out["note"] = ("merge failed with no conflicts: " + " / ".join(tail[-3:]) + if tail else "merge failed and git said nothing") run(["git", "merge", "--abort"], cwd=repo, check=False) return out out["hunks"] = [