{"record":{"id":"866e13066d99f0b6","repo":"GitoxideLabs/gitoxide","slug":"a-reference-name-is-empty","errorCode":null,"errorMessage":"a reference name is empty","messagePattern":"a reference name is empty","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/todo.rs","lineNumber":1118,"sourceCode":"        anyhow::bail!(\"a quoted reference name is not closed\");\n    }\n    ranges.push(&body[start..]);\n    let mut out = Vec::with_capacity(ranges.len());\n    for item in ranges {\n        let item = item.trim();\n        if item.is_empty() {\n            anyhow::bail!(\"a reference line contains an empty name\");\n        }\n        let (marked, item) = item.strip_prefix('@').map_or((false, item), |item| (true, item));\n        let encoded = item.as_bytes().as_bstr();\n        let (name, consumed) = gix::quote::ansi_c::undo(encoded)\n            .map_err(gix::Exn::into_error)\n            .context(\"could not unquote a reference name\")?;\n        if !encoded[consumed..].trim().is_empty() {\n            anyhow::bail!(\"a reference name has trailing data\");\n        }\n        if name.is_empty() {\n            anyhow::bail!(\"a reference name is empty\");\n        }\n        out.push((marked, name.into_owned()));\n    }\n    Ok(out)\n}\n\nfn resolve_ref_name(\n    repo: &gix::Repository,\n    refs: &mut Vec<rebase::ExpectedRef>,\n    input: &gix::bstr::BStr,\n) -> Result<gix::refs::FullName> {\n    let mut matches = refs\n        .iter()\n        .filter(|reference| reference.editable && ref_display_name(&reference.name, refs).as_bstr() == input)\n        .map(|reference| reference.name.clone());\n    if let Some(name) = matches.next() {\n        if matches.next().is_some() {\n            anyhow::bail!(\"the shortened reference name is ambiguous\");","sourceCodeStart":1100,"sourceCodeEnd":1136,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/todo.rs#L1100-L1136","documentation":"After ANSI-C unquoting, a reference item may decode to an empty name (e.g. an item that was only quotes: `\"\"` or `\"@\"` with an empty inner value). Since an empty reference name is meaningless in a Git plan, `parse_ref_line` throws this error rather than inserting a placeholder ref.","triggerScenarios":"Calling `parse` with reference items like `(\"\")` or `(\"\" , name2)` where the quoted name unquotes to the empty string.","commonSituations":"A placeholder `\"\"` left in a generated or hand-edited reference list; a script emitting empty names when the ref variable is unset.","solutions":["Replace the empty quoted name with the actual reference full name, e.g. `refs/heads/main`.","Remove the empty item (and its comma) from the reference line entirely.","Fix the generating script/variable so a real ref name is emitted instead of `\"\"`."],"exampleFix":"// before\n(\"\", refs/tags/v1)\n\n// after\n(refs/heads/main, refs/tags/v1)","handlingStrategy":"validation","validationCode":"// Rust: reject items that unquote to empty names\nfn item_name_nonempty(item: &str) -> bool {\n    !item.trim().trim_start_matches('@').trim_matches('\"').is_empty()\n}","typeGuard":null,"tryCatchPattern":"match parse_plan(&repo, text) {\n    Ok(plan) => apply(plan),\n    Err(e) if e.to_string().contains(\"reference name is empty\") => {\n        eprintln!(\"Replace the empty quoted name with a real reference name.\");\n        Err(e)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never emit `\"\"` placeholders in generated reference lists.","Check that ref-name variables are set before templating the todo.","Require full names like `refs/heads/<branch>` in reference lines."],"tags":["parsing","refs","validation"],"backgroundTag":"empty-required-field","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}