fix(git_status): Avoid printing error on missing stash ref (#5434)

* fix(git_status): Avoid printing error on missing stash ref

* ensure we only proceed if the returned reference has the expected name
This commit is contained in:
David Knaack 2023-12-16 16:58:45 +01:00 committed by GitHub
parent e79014a99f
commit 00d3dc86a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -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;
}
};
@ -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
}
}