{"record":{"id":"b57ec69c2a24c6c9","repo":"gitbutlerapp/gitbutler","slug":"commit-id-is-ambiguous-found-matches","errorCode":null,"errorMessage":"Commit ID '{}' is ambiguous. Found {} matches","messagePattern":"Commit ID '(.+?)' is ambiguous\\. Found (.+?) matches","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/show.rs","lineNumber":67,"sourceCode":"        }\n    }\n\n    // Not a branch, resolve the commit ID through the IdMap\n    let cli_ids = id_map.parse_using_context(commit_id_str, ctx)?;\n\n    let commit_id = if cli_ids.is_empty() {\n        // If not found in IdMap, try to parse as a git commit ID directly\n        let repo = ctx.repo.get()?;\n        let obj = repo\n            .rev_parse_single(commit_id_str)\n            .map_err(|_| anyhow::anyhow!(\"Commit '{commit_id_str}' not found\"))?;\n        let commit = obj\n            .object()?\n            .try_into_commit()\n            .map_err(|_| anyhow::anyhow!(\"'{commit_id_str}' is not a commit\"))?;\n        commit.id\n    } else if cli_ids.len() > 1 {\n        bail!(\n            \"Commit ID '{}' is ambiguous. Found {} matches\",\n            commit_id_str,\n            cli_ids.len()\n        );\n    } else {\n        match &cli_ids[0] {\n            CliId::Commit {\n                commit: CommitId { commit_id, .. },\n                id: _,\n            } => *commit_id,\n            CliId::Branch(branch) => {\n                // This is a branch identified by CLI ID, show the branch\n                return show_branch(ctx, out, &branch.name, verbose, &id_map);\n            }\n            _ => {\n                bail!(\n                    \"Target must be a commit ID or branch, not {}\",\n                    cli_ids[0].kind_for_humans()","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/show.rs#L49-L85","documentation":"In `but show`, a user-supplied ID string is resolved to `CliId`s; if the string matches more than one object, `show_commit` cannot pick one and reports the number of matches. This guards against showing the wrong commit when short IDs or names are ambiguous.","triggerScenarios":"Passing a short commit hash prefix that matches multiple commits (e.g. `but show 12ab` where several objects start with `12ab`), when `cli_ids.len() > 1` after resolution.","commonSituations":"Very short hash prefixes in large repositories; copy-pasting a truncated hash; branch/tag and commit sharing a prefix in the ID map.","solutions":["Use a longer (ideally full 40-char) commit hash: `but show 12ab34cd...`.","List candidates first (e.g. `but log` / `but branches`) and pick the exact ID.","If your tooling passes IDs programmatically, resolve via the ID map with full IDs from prior command output."],"exampleFix":"// before\nbut show 12ab\n// error: ambiguous, 3 matches\n// after\nbut show 12ab34cd56ef78ab90cd12ef34ab56cd78ab90cd","handlingStrategy":"validation","validationCode":"fn disambiguate(ids: &[CliId], raw: &str) -> Result<&CliId, String> {\n    match ids {\n        [one] => Ok(one),\n        [] => Err(format!(\"no object matches '{raw}'\")),\n        many => Err(format!(\"'{raw}' is ambiguous ({} matches); use a longer hash\", many.len())),\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"is ambiguous\") => {\n        eprintln!(\"use the full 40-character commit hash\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Use full commit hashes in scripts, not short prefixes","Resolve IDs from prior command output's full-ID fields","Keep prefix length >= 8-12 chars when typing by hand"],"tags":["cli","ambiguity","commit-id","resolution"],"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"}