{"record":{"id":"9f482f5f375612f6","repo":"GitoxideLabs/gitoxide","slug":"pasted-object-is-not-a-commit","errorCode":null,"errorMessage":"pasted object is not a commit","messagePattern":"pasted object is not a commit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/lib.rs","lineNumber":7028,"sourceCode":"            })\n        }\n    }\n}\n\nfn resolve_pasted_commit(repository: &gix::Repository, pasted: &str) -> Result<gix::ObjectId> {\n    let hash = pasted.trim();\n    anyhow::ensure!(\n        !hash.is_empty() && hash.bytes().all(|byte| byte.is_ascii_hexdigit()),\n        \"expected exactly one hexadecimal commit ID\"\n    );\n    let object = repository\n        .rev_parse(hash.as_bytes().as_bstr())\n        .context(\"could not resolve pasted commit ID\")?\n        .single()\n        .context(\"pasted commit ID is ambiguous\")?\n        .object()\n        .context(\"could not read pasted object\")?;\n    anyhow::ensure!(\n        object.kind == gix::object::Kind::Commit,\n        \"pasted object is not a commit\"\n    );\n    Ok(object.id)\n}\n\nfn diagnostic_key(character: char) -> KeyEvent {\n    let code = match character {\n        '\\t' => KeyCode::Tab,\n        '\\n' | '\\r' => KeyCode::Enter,\n        '\\u{1b}' => KeyCode::Esc,\n        character => KeyCode::Char(character),\n    };\n    let modifiers = if character.is_uppercase() {\n        KeyModifiers::SHIFT\n    } else {\n        KeyModifiers::NONE\n    };","sourceCodeStart":7010,"sourceCodeEnd":7046,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/lib.rs#L7010-L7046","documentation":"`resolve_pasted_commit` successfully resolved the pasted hex to an object, but that object is not of kind `gix::object::Kind::Commit`. The function contractually returns a commit ID, so non-commit objects (blob, tree, tag-object) are rejected with this `ensure!`.","triggerScenarios":"Pasting the hex ID of a blob or tree (e.g. copied from `git ls-tree` or `git cat-file` output) into the commit-paste flow, or a lightweight tag's target ambiguity where the resolved object is the tagged blob/tree (gix-tix/src/lib.rs:7028).","commonSituations":"Copy-pasting object IDs from `git cat-file --batch-check`, GitHub URLs that reference blobs (`/blob/<sha>`), or tree IDs from tree listings; repos where a tag object was pasted (tag kind, not commit).","solutions":["Paste a commit object ID: get one with `git rev-parse <ref>^{commit}`.","If you have a tag object ID, peel it first: `git rev-parse <tag>^{}` resolves to the commit.","If you have a blob/tree ID, look up the containing commit instead of pasting the raw object ID.","To support other kinds, check `object.kind` in `resolve_pasted_commit` and peel tags via `object.peel_to_kind(Kind::Commit)` before rejecting."],"exampleFix":"// before\nlet object = repo.rev_parse(hex)?.single()?.object()?;\nanyhow::ensure!(object.kind == Kind::Commit, \"pasted object is not a commit\");\n// after\nlet object = repo.rev_parse(hex)?.single()?.object()?;\nlet commit = object.peel_to_kind(gix::object::Kind::Commit)\n    .context(\"pasted object does not peel to a commit\")?;","handlingStrategy":"validation","validationCode":"let kind = repo.rev_parse(pasted.trim().as_bytes().as_bstr())?\n    .single().ok()\n    .and_then(|id| id.object().ok())\n    .map(|o| o.kind);\nif kind != Some(gix::object::Kind::Commit) { /* peel or reject before calling */ }","typeGuard":"fn is_commit_object(kind: gix::object::Kind) -> bool {\n    kind == gix::object::Kind::Commit\n}","tryCatchPattern":"match resolve_pasted_commit(&repo, pasted) {\n    Err(e) if e.to_string().contains(\"pasted object is not a commit\") => {\n        eprintln!(\"Peel tags / use the containing commit: git rev-parse <id>^{{commit}}\");\n    }\n    res => res?,\n}","preventionTips":["Peel IDs with `<id>^{commit}` before pasting when the source may be a tag","Do not copy blob/tree IDs from `git ls-tree` or GitHub blob URLs into commit pickers","Check `git cat-file -t <id>` equals `commit` before use","When in doubt, resolve a branch name to its commit instead of pasting raw object IDs"],"tags":["validation","git-object","type-mismatch","commit"],"backgroundTag":"type-mismatch","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}