{"record":{"id":"dc8be060c88ed36a","repo":"gitui-org/gitui","slug":"could-not-select-commit-it-might-not-be-loaded-ye","errorCode":null,"errorMessage":"Could not select commit. It might not be loaded yet or it might be on a different branch.","messagePattern":"Could not select commit\\. It might not be loaded yet or it might be on a different branch\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"src/components/commitlist.rs","lineNumber":259,"sourceCode":"\t\t} else {\n\t\t\thighlighting\n\t\t};\n\n\t\tself.select_next_highlight();\n\t\tself.set_highlighted_selection_index();\n\t\tself.fetch_commits(true);\n\t}\n\n\t///\n\tpub fn select_commit(&mut self, id: CommitId) -> Result<()> {\n\t\tlet index = self.commits.get_index_of(&id);\n\n\t\tif let Some(index) = index {\n\t\t\tself.selection = index;\n\t\t\tself.set_highlighted_selection_index();\n\t\t\tOk(())\n\t\t} else {\n\t\t\tanyhow::bail!(\"Could not select commit. It might not be loaded yet or it might be on a different branch.\");\n\t\t}\n\t}\n\n\t///\n\tpub fn highlighted_selection_info(&self) -> (usize, usize) {\n\t\tlet amount = self\n\t\t\t.highlights\n\t\t\t.as_ref()\n\t\t\t.map(|highlights| highlights.len())\n\t\t\t.unwrap_or_default();\n\t\t(self.highlighted_selection.unwrap_or_default(), amount)\n\t}\n\n\tfn set_highlighted_selection_index(&mut self) {\n\t\tself.highlighted_selection =\n\t\t\tself.highlights.as_ref().and_then(|highlights| {\n\t\t\t\thighlights.iter().position(|entry| {\n\t\t\t\t\tentry == &self.commits[self.selection]","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/gitui-org/gitui/blob/2fa693cb6ed431b21ebc300dd02e83c2476699ce/src/components/commitlist.rs#L241-L277","documentation":"The Revlog component's select_commit() looks the given CommitId up in the list of commits currently materialized in the log view (slabvec of loaded entries). When get_index_of returns None it bails with this message: the id is not in the loaded window - not yet paged in, filtered out by the current branch filter, or reachable only from another branch. It is a soft lookup failure, not repo corruption.","triggerScenarios":"Calling select_commit right after opening the revlog before the asynchronous history fetch lands; targeting a commit older than the loaded window; the id living on an unmerged branch while the list is filtered to the current one; a stale id after a rebase rewrote history.","commonSituations":"Deep-linking from file history or blame to an old commit; automation driving gitui's components programmatically; selecting ids taken from another worktree or a reflog.","solutions":["Retry after the history has loaded - give the async fetch a beat or trigger fetch_commits(true) first.","Scroll/paginate the log so the target commit is inside the loaded window, or increase the loaded revlog size.","Verify the commit exists and where: git cat-file -t <sha> and git branch --contains <sha>.","Check out the containing branch first, then select the commit."],"exampleFix":"// before\nrevlog.select_commit(id)?;\n// after: tolerate not-yet-loaded ids and retry once after a fetch\nif revlog.select_commit(id).is_err() {\n    revlog.fetch_commits(true);\n    revlog.select_commit(id)?;\n}","handlingStrategy":"retry","validationCode":"// confirm the id is at least reachable in the repo before driving the UI\nlet obj = repo.revparse_single(&id.to_string())?;\nif !obj.as_commit().is_some_and(|_| true) { /* don't call select_commit at all */ }","typeGuard":null,"tryCatchPattern":"match revlog.select_commit(id) {\n    Ok(()) => {}\n    Err(e) if e.to_string().contains(\"not be loaded\") => {\n        wait_for_revlog_load();   // one event-loop tick / input-thread notification\n        let _ = revlog.select_commit(id); // best effort second try\n    }\n    e => e?,\n}","preventionTips":["Give asynchronous history loading a beat before programmatically selecting commits.","Prefer selecting from refs you know are loaded (current branch) before jumping to arbitrary shas.","Treat this bail as 'retry later', not as corruption."],"tags":["revlog","commit","not-found","async-loading","selection"],"backgroundTag":"commit-not-found","analyzedSha":"2fa693cb6ed431b21ebc300dd02e83c2476699ce","analyzedAt":"2026-08-16T23:07:36.562Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}