{"record":{"id":"daa433985208823f","repo":"GitoxideLabs/gitoxide","slug":"a-reference-is-placed-more-than-once","errorCode":null,"errorMessage":"a reference is placed more than once","messagePattern":"a reference is placed more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/todo.rs","lineNumber":900,"sourceCode":"            )?;\n            cursor = Some(if let Some(index) = picked.get(&id) {\n                rebase::PlanParent::Step(*index)\n            } else if scope.contains(&id) {\n                anyhow::bail!(\"a fork target must be picked before it is used\");\n            } else {\n                rebase::PlanParent::Existing(id)\n            });\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\")?;","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/todo.rs#L882-L918","documentation":"Each reference name may be positioned (moved to a commit) at most once within a rebase todo. If the same ref appears in reference lines under two different fork/command sections, the parser cannot decide a single new target for it and bails.","triggerScenarios":"`parse` bails when `ref_targets.insert(name, target)` returns Some — i.e. `parse_ref_line` yielded a ref whose name was already recorded for a different (or same) position. Happens when a user duplicates a `(refs/heads/...)` line across fork sections while editing the todo.","commonSituations":"Copy-pasting reference lines while rearranging sections; forgetting that moving a ref line relocates it (the original must be removed); template mistakes.","solutions":["Remove the duplicate reference line, keeping only the one in the desired section","If the ref should not move at all, delete both lines and let tix keep it at its current position","Reopen the todo to regenerate a clean template before re-editing"],"exampleFix":"// before\n──fork abc1234──\n(main)\n──fork def5678──\n(main)\n// after\n──fork abc1234──\n(main)\n──fork def5678──\n(no ref line for main)","handlingStrategy":"validation","validationCode":"let mut seen = HashSet::new();\nfor name in ref_names_in_todo(edited) {\n    if !seen.insert(name.clone()) {\n        return Err(format!(\"ref {} appears more than once\", name));\n    }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = parse(repo, edited) {\n    if e.to_string().contains(\"placed more than once\") {\n        // highlight the duplicated ref line for the user\n    }\n}","preventionTips":["Move a ref line instead of copying it","Search the todo for the ref name before re-adding it","Use one reference line per ref across all sections"],"tags":["rebase","todo-parsing","duplicate-reference"],"backgroundTag":"schema-validation-failed","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"}