{"record":{"id":"e7c53bc0f648c92b","repo":"gitbutlerapp/gitbutler","slug":"commit-prefix-spec-is-ambiguous","errorCode":null,"errorMessage":"commit prefix '{spec}' is ambiguous","messagePattern":"commit prefix '(.+?)' is ambiguous","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs","lineNumber":161,"sourceCode":"                commit.target_relation,\n                IntegrationDivergenceTargetRelation::NotIntegrated\n            )\n        })\n        .map(|commit| commit.id)\n        .chain(divergence.upstream_only.iter().map(|commit| commit.id))\n        .collect()\n}\n\nfn resolve_commit(spec: &str, allowed_commits: &HashSet<gix::ObjectId>) -> Result<gix::ObjectId> {\n    let matches = allowed_commits\n        .iter()\n        .copied()\n        .filter(|commit_id| commit_id.to_string().starts_with(spec))\n        .collect::<Vec<_>>();\n    match matches.as_slice() {\n        [] => bail!(\"commit '{spec}' is not part of the editable divergence\"),\n        [commit_id] => Ok(*commit_id),\n        _ => bail!(\"commit prefix '{spec}' is ambiguous\"),\n    }\n}\n\nfn split_message_clause(line: &str) -> Result<(&str, Option<&str>)> {\n    let Some((command_part, message_part)) = line.split_once('|') else {\n        return Ok((line, None));\n    };\n    Ok((command_part.trim_end(), Some(message_part.trim_start())))\n}\n\nfn parse_message_clause(clause: &str) -> Result<String> {\n    let value = clause\n        .strip_prefix(\"message=\")\n        .context(\"expected `message=` after `|`\")?;\n    parse_quoted_string(value)\n}\n\nfn parse_quoted_string(input: &str) -> Result<String> {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs#L143-L179","documentation":"Commit specs in the integration script are resolved by hex-prefix matching against the editable divergence commits. If the given prefix matches two or more commits, resolution is impossible and this error is raised rather than guessing. It surfaces wrapped as `line N: invalid pick/merge/squash commit: commit prefix '<spec>' is ambiguous`.","triggerScenarios":"Calling parse_integration_steps_script with an abbreviated hash that is a prefix of multiple allowed commit ids — e.g. `pick abcdef` when both `abcdef0aaa...` and `abcdef1aaa...` are in the divergence.","commonSituations":"Users type very short hashes (4–6 chars) while a divergence contains many nearby commits, or scripts written against one divergence state are reused after upstream changes introduced new commits sharing a prefix.","solutions":["Lengthen the hash until it is unique — the rendered script uses 7-character short ids; use at least that many, or the full 40-char hash.","Copy the exact short id from the rendered script rather than typing an abbreviation by hand.","Use the full commit hash, which the parser explicitly accepts (`accepts_full_hashes`)."],"exampleFix":"// before (script text — 'abcdef' matches two commits)\npick abcdef\n// after\npick abcdef0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n","handlingStrategy":"validation","validationCode":"function validateUnambiguous(script: string, allowedIds: string[]): string[] {\n  return script.split('\\n').flatMap((line, i) => {\n    const [cmd, ...args] = line.split('|')[0].trim().split(/\\s+/).filter(Boolean);\n    if (!['pick', 'merge', 'squash'].includes(cmd)) return [];\n    return args\n      .filter(a => allowedIds.filter(id => id.startsWith(a)).length > 1)\n      .map(a => `line ${i + 1}: commit prefix '${a}' is ambiguous`);\n  });\n}","typeGuard":"const prefixIsUnique = (spec: string, allowedIds: string[]): boolean =>\n  allowedIds.filter(id => id.startsWith(spec)).length === 1;","tryCatchPattern":"try {\n  const steps = await parseIntegrationScript(script, divergence);\n} catch (err) {\n  const m = /line (\\d+): invalid \\w+ commit: commit prefix '([^']+)' is ambiguous/.exec(String(err));\n  if (m) showEditorErrorAtLine(Number(m[1]), `lengthen hash '${m[2]}' to make it unique`);\n  else throw err;\n}","preventionTips":["Use at least 7 hex characters, matching the rendered short-id length.","Copy-paste short ids from the rendered script instead of typing abbreviations.","Full 40-character hashes are always unambiguous and accepted."],"tags":["parsing","git","commit-resolution","ambiguity"],"backgroundTag":"invalid-identifier-format","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}