gitui-org/gitui · critical
Could not get status
Error message
Could not get status
What it means
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.
Source
Thrown at src/popups/branchlist.rs:590
span_msg,
]));
}
Text::from(txt)
}
///
fn switch_to_selected_branch(&mut self) -> Result<()> {
if !self.valid_selection() {
anyhow::bail!("no valid branch selected");
}
let status = sync::status::get_status(
&self.repo.borrow(),
StatusType::WorkingDir,
None,
)
.expect("Could not get status");
let selected_branch = &self.branches[self.selection as usize];
if status.is_empty() {
if self.local {
checkout_branch(
&self.repo.borrow(),
&selected_branch.name,
)?;
self.hide();
} else {
checkout_remote_branch(
&self.repo.borrow(),
selected_branch,
)?;
self.local = true;
self.update_branches()?;
}
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));View on GitHub (pinned to 2fa693cb6e)
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.
Example fix
# before: panic 'Could not get status' when switching branches ls -la .git/index.lock # stale lock present # after rm .git/index.lock && git status && gitui
Defensive patterns
Strategy: validation
Validate before calling
# before switching branches via the popup
[ ! -e .git/index.lock ] || echo 'git busy or stale lock present'
git status >/dev/null 2>&1 && echo 'status readable'
// Rust: probe for the lock before triggering the popup action
let lock = repo.workdir().map(|w| w.join(".git").join("index.lock")).filter(|p| p.exists());
if lock.is_some() { /* defer the switch, notify user */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: IDE git integrations racing manual TUI usage; crash remnants after OOM kills or forced shutdowns; network filesystems with lingering lock files.
Related errors
AI-assisted analysis of gitui-org/gitui@2fa693cb6e (2026-08-16).
Data as JSON: /api/errors/066eb3572f09bb98.
Report an issue: GitHub.