{"record":{"id":"72d70a23e1952fbc","repo":"GitoxideLabs/gitoxide","slug":"the-rebase-todo-contains-more-than-one-reference","errorCode":null,"errorMessage":"the rebase todo contains more than one @ reference","messagePattern":"the rebase todo contains more than one @ reference","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/todo.rs","lineNumber":907,"sourceCode":"            });\n            sections += 1;\n            section_has_commit = false;\n            section_last_step = None;\n            continue;\n        }\n        if line.starts_with('(') && line.ends_with(')') {\n            let target = cursor.context(\"a reference line must follow a fork or command\")?;\n            for (marked, value) in parse_ref_line(line)? {\n                let name = resolve_ref_name(repo, &mut state.expected_refs, value.as_bstr())?;\n                if ref_targets.insert(name.clone(), target).is_some() {\n                    anyhow::bail!(\"a reference is placed more than once\");\n                }\n                if marked {\n                    if !state.checkout_allowed || repo.workdir().is_none() {\n                        anyhow::bail!(\"the rebase todo cannot select a checkout without a worktree\");\n                    }\n                    if explicit_checkout_reference.replace((name, target)).is_some() {\n                        anyhow::bail!(\"the rebase todo contains more than one @ reference\");\n                    }\n                }\n            }\n            section_has_commit = true;\n            continue;\n        }\n\n        let (command, tail) = if let Some(line) = line.strip_prefix('`') {\n            let (command, tail) = line\n                .split_once('`')\n                .context(\"a Markdown todo command has no closing backtick\")?;\n            (command, tail.trim())\n        } else {\n            (line, \"\")\n        };\n        let (verb, value) = command.split_once(char::is_whitespace).unwrap_or((command, \"\"));\n        let marked = verb.starts_with('@');\n        let verb = verb.strip_prefix('@').unwrap_or(verb);","sourceCodeStart":889,"sourceCodeEnd":925,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/todo.rs#L889-L925","documentation":"Validation inside `edit::todo::parse`, which turns a user-edited rebase-todo file into a `rebase::Plan`. When parsing a `(ref)` line that follows a fork or command heading, each resolved reference name is inserted into `ref_targets`; a duplicate name means the user placed the same reference more than once in the todo. The plan would otherwise silently drop or ambiguously apply reference moves, so parsing aborts. Triggered by hand-edited todo files with repeated ref lines; the fix is to remove the duplicate reference entry so each branch/HEAD is positioned at most once.","triggerScenarios":"`parse` bails when `explicit_checkout_reference.replace((name, target))` returns Some — i.e. a second `@`-marked reference line was encountered after one was already recorded. Happens when a user marks multiple refs with `@` while editing the todo.","commonSituations":"Marking several branch lines with `@` to 'check out wherever'; copy-paste duplication of a marked line; misunderstanding the single-checkout rule.","solutions":["Keep `@` on exactly one reference line and remove it from the others","Decide which branch/commit should be checked out after the rebase and mark only that one","Reopen the todo to regenerate the template and reapply a single `@` marker"],"exampleFix":"// before\n(main @)\n(feature @)\n// after\n(main @)\n(feature)","handlingStrategy":"validation","validationCode":"let markers = ref_lines(edited).filter(|l| l.contains(\"@\")).count();\nif markers > 1 {\n    return Err(\"only one @ checkout selection is allowed\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = parse(repo, edited) {\n    if e.to_string().contains(\"more than one @ reference\") {\n        // ask the user which single ref to check out\n    }\n}","preventionTips":["Mark exactly one ref with `@` per todo","Treat `@` as the single final checkout choice, not a per-branch flag","Validate edited todos in the editor before saving"],"tags":["rebase","todo-parsing","checkout-selection"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}