{"record":{"id":"066eb3572f09bb98","repo":"gitui-org/gitui","slug":"could-not-get-status","errorCode":null,"errorMessage":"Could not get status","messagePattern":"Could not get status","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/popups/branchlist.rs","lineNumber":590,"sourceCode":"\t\t\t\tspan_msg,\n\t\t\t]));\n\t\t}\n\n\t\tText::from(txt)\n\t}\n\n\t///\n\tfn switch_to_selected_branch(&mut self) -> Result<()> {\n\t\tif !self.valid_selection() {\n\t\t\tanyhow::bail!(\"no valid branch selected\");\n\t\t}\n\n\t\tlet status = sync::status::get_status(\n\t\t\t&self.repo.borrow(),\n\t\t\tStatusType::WorkingDir,\n\t\t\tNone,\n\t\t)\n\t\t.expect(\"Could not get status\");\n\n\t\tlet selected_branch = &self.branches[self.selection as usize];\n\t\tif status.is_empty() {\n\t\t\tif self.local {\n\t\t\t\tcheckout_branch(\n\t\t\t\t\t&self.repo.borrow(),\n\t\t\t\t\t&selected_branch.name,\n\t\t\t\t)?;\n\t\t\t\tself.hide();\n\t\t\t} else {\n\t\t\t\tcheckout_remote_branch(\n\t\t\t\t\t&self.repo.borrow(),\n\t\t\t\t\tselected_branch,\n\t\t\t\t)?;\n\t\t\t\tself.local = true;\n\t\t\t\tself.update_branches()?;\n\t\t\t}\n\t\t\tself.queue.push(InternalEvent::Update(NeedsUpdate::ALL));","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/gitui-org/gitui/blob/2fa693cb6ed431b21ebc300dd02e83c2476699ce/src/popups/branchlist.rs#L572-L608","documentation":"switch_to_selected_branch() calls sync::status::get_status() to check the working directory for pending changes and immediately .expect()s the result. get_status wraps libgit2's status enumeration; it returns Err when the worktree or index cannot be read - most often because .git/index.lock exists (concurrent git process or a stale lock from a crashed one), also corrupt index files or permission problems. The expect panics, tearing down the TUI.","triggerScenarios":"Another git process (IDE background indexing, editor integration, background fetch) holding .git/index.lock at the moment you press enter in gitui's branch popup; a previously killed gitui or git leaving a stale lock; an index damaged by disk issues.","commonSituations":"IDE git integrations racing manual TUI usage; crash remnants after OOM kills or forced shutdowns; network filesystems with lingering lock files.","solutions":["Check for the lock: ls -la .git/index.lock - if present and no git process is running (ps aux | grep git), remove it: rm .git/index.lock.","Validate repo health from a shell: git status; if the index is corrupt, git reset rebuilds it (re-clone as a last resort).","Retry the branch switch in gitui afterwards.","Update gitui - newer versions propagate this failure as an error instead of a panic."],"exampleFix":"# before: panic 'Could not get status' when switching branches\nls -la .git/index.lock    # stale lock present\n# after\nrm .git/index.lock && git status && gitui","handlingStrategy":"validation","validationCode":"# before switching branches via the popup\n[ ! -e .git/index.lock ] || echo 'git busy or stale lock present'\ngit status >/dev/null 2>&1 && echo 'status readable'\n\n// Rust: probe for the lock before triggering the popup action\nlet lock = repo.workdir().map(|w| w.join(\".git\").join(\"index.lock\")).filter(|p| p.exists());\nif lock.is_some() { /* defer the switch, notify user */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid running IDE git integrations and gitui's branch switch at the same time.","Remove stale .git/index.lock after any hard-killed git process - after confirming none is running.","Prefer gitui versions that surface get_status failures as errors rather than expect-panics."],"tags":["panic","git-index","index-lock","libgit2","branch-switch"],"backgroundTag":"git-index-locked","analyzedSha":"2fa693cb6ed431b21ebc300dd02e83c2476699ce","analyzedAt":"2026-08-16T23:07:36.562Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}