Skip to content

Commit

Permalink
fix(git_status): Avoid printing error on missing stash ref (#5434)
Browse files Browse the repository at this point in the history
* fix(git_status): Avoid printing error on missing stash ref

* ensure we only proceed if the returned reference has the expected name
  • Loading branch information
davidkna committed Dec 16, 2023
1 parent e79014a commit 00d3dc8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/git_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,12 @@ fn get_repo_status(
fn get_stashed_count(repo: &context::Repo) -> Option<usize> {
let repo = repo.open();
let reference = match repo.try_find_reference("refs/stash") {
Ok(Some(reference)) => reference,
// Only proceed if the found reference has the expected name (not tags/refs/stash etc.)
Ok(Some(reference)) if reference.name().as_bstr() == b"refs/stash".as_slice() => reference,
// No stash reference found
Ok(None) => return Some(0),
Ok(_) => return Some(0),
Err(err) => {
log::warn!("Error finding stash reference: {err}");
log::debug!("Error finding stash reference: {err}");
return None;
}
};
Expand All @@ -272,7 +273,7 @@ fn get_stashed_count(repo: &context::Repo) -> Option<usize> {
Some(0)
}
Err(err) => {
log::warn!("Error getting stash log: {err}");
log::debug!("Error getting stash log: {err}");
None
}
}
Expand Down

0 comments on commit 00d3dc8

Please sign in to comment.