{"record":{"id":"c84435ff4b9f7dc0","repo":"gitbutlerapp/gitbutler","slug":"well-formed-root-ref","errorCode":null,"errorMessage":"well-formed root ref","messagePattern":"well-formed root ref","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/but-workspace/src/branch/apply.rs","lineNumber":1069,"sourceCode":"fn set_head_to_reference(\n    repo: &gix::Repository,\n    new_ref_target: gix::ObjectId,\n    new_ref: Option<&gix::refs::FullNameRef>,\n) -> anyhow::Result<()> {\n    let edits = match new_ref {\n        None => {\n            let head_message = \"GitButler checkout workspace during apply-branch\".into();\n            vec![RefEdit {\n                change: Change::Update {\n                    log: LogChange {\n                        mode: RefLog::AndReference,\n                        force_create_reflog: false,\n                        message: head_message,\n                    },\n                    expected: PreviousValue::Any,\n                    new: Target::Object(new_ref_target),\n                },\n                name: \"HEAD\".try_into().expect(\"well-formed root ref\"),\n                deref: true,\n            }]\n        }\n        Some(new_ref) => {\n            // This also means we want HEAD to point to it.\n            let head_message = \"GitButler switch to workspace during apply-branch\".into();\n            vec![\n                RefEdit {\n                    change: Change::Update {\n                        log: LogChange {\n                            mode: RefLog::AndReference,\n                            force_create_reflog: false,\n                            message: head_message,\n                        },\n                        expected: PreviousValue::Any,\n                        new: Target::Symbolic(new_ref.to_owned()),\n                    },\n                    name: \"HEAD\".try_into().expect(\"well-formed root ref\"),","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/apply.rs#L1051-L1087","documentation":"Panic from `expect(\"well-formed root ref\")` after `\"HEAD\".try_into()` in `apply.rs:1069` (but-workspace). It converts the literal string `HEAD` into a gix partial ref name for a RefEdit that updates HEAD (deref mode) when there is no workspace ref to point at. Parsing the fixed string `HEAD` cannot fail under gix's validation rules, so this is a static-invariant assertion, not a runtime risk.","triggerScenarios":"Executed on the apply-branch path where no `new_ref` exists and HEAD must be moved directly to the new workspace target; would only panic if the literal were changed to something that is not a valid ref name.","commonSituations":"None in stock builds; only forks or hand-edited patches that alter the literal.","solutions":["No action needed — the literal is valid by construction","If patching this area, keep the string `HEAD` or reuse gix's existing HEAD name constant instead of re-parsing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Nothing to guard: the parsed literal is the fixed string HEAD","Keep the literal unchanged when patching apply-branch code"],"tags":["rust","panic","expect","git-ref-name","head-ref","static-constant","gix"],"backgroundTag":"git-ref-name-parse-failure","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}