GitoxideLabs/gitoxide · error
a captured ref name has trailing data
Error message
a captured ref name has trailing data
What it means
For each `ref` line captured in the rebase state, `parse_state` unquotes the ref name with `gix::quote::ansi_c::undo` and requires the remaining bytes after the quoted name to be empty after trimming. Leftover characters mean the captured ref name is followed by unexpected data, so the state is rejected as malformed.
Solutions
- Fix the `ref` line so the name is a single C-quoted fully-qualified ref (quote names containing spaces or special characters).
- Remove any stray characters after the quoted ref name.
- Regenerate the state by re-running the rebase/edit operation.
Example fix
// before (state file) ref abc123 fast-forward refs/heads/wip extra // after ref abc123 fast-forward "refs/heads/wip"
Defensive patterns
Strategy: validation
Validate before calling
fn ref_name_field_is_clean(value: &str) -> bool {
value.split_whitespace().count() == 3
} Try / catch
match todo::parse(state_text) {
Ok(state) => apply(state),
Err(e) if e.to_string().contains("captured ref name has trailing data") => {
eprintln!("fix the ref line: quote the name, remove trailing tokens");
}
Err(e) => return Err(e),
} Prevention
- Always C-quote captured ref names (gix::quote::ansi_c) when writing state.
- Validate each ref line has exactly old/target/name fields before saving.
- Test state round-trips (write then parse) in automation.
When it happens
Trigger: `parse_state` (gix-tix/src/edit/todo.rs:735) parsing a `ref <old> <target> <quoted-name>` line where the name field carries trailing tokens, e.g. an extra value or a mangled quote sequence that fails to consume the whole name field.
Common situations: Hand-edited `ref` lines; names containing spaces that were not properly C-quoted; corruption from interrupted writes; mismatched state format versions.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- the recorded HEAD ref has trailing data
- the rebase state repeats marker-required
- the rebase state repeats checkout-allowed
- the rebase state repeats its HEAD ref
- the rebase state repeats its resolved conflict
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/1b74289cad896096.
Report an issue: GitHub.
Appendix: source
Thrown at gix-tix/src/edit/todo.rs:735
}
"edit-refs" => edit_refs = value.parse()?,
"ref" => {
let (old, value) = value.split_once(' ').context("a captured ref has no target")?;
let (target, value) = value.split_once(' ').context("a captured ref has no follow mode")?;
let old = (old != "-").then(|| ObjectId::from_hex(old.as_bytes())).transpose()?;
let target = ObjectId::from_hex(target.as_bytes())?;
let (follows_tip, value) = value.split_once(' ').context("a captured ref has no name")?;
let follows_tip = follows_tip.parse()?;
let (editable, name) = value
.split_once(' ')
.and_then(|(editable, name)| editable.parse::<bool>().ok().map(|editable| (editable, name)))
.unwrap_or((false, value));
let encoded_name = name.as_bytes().as_bstr();
let (name, consumed) = gix::quote::ansi_c::undo(encoded_name)
.map_err(gix::Exn::into_error)
.context("could not unquote a captured ref name")?;
if !encoded_name[consumed..].trim().is_empty() {
anyhow::bail!("a captured ref name has trailing data");
}
let name = gix::refs::FullName::try_from(name.as_ref()).context("a captured ref name is invalid")?;
expected_refs.push(rebase::ExpectedRef {
name,
old,
target,
new: old,
follows_tip,
editable,
placement: None,
});
}
"resolved" => {
if resolved.replace(ObjectId::from_hex(value.as_bytes())?).is_some() {
anyhow::bail!("the rebase state repeats its resolved conflict");
}
}
"continuation-source" => continuation_sources.push(ObjectId::from_hex(value.as_bytes())?),View on GitHub (pinned to e73179060b)