1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-03 00:50:50 +00:00

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

View File

@ -256,11 +256,12 @@ fn get_repo_status(
fn get_stashed_count(repo: &context::Repo) -> Option<usize> { fn get_stashed_count(repo: &context::Repo) -> Option<usize> {
let repo = repo.open(); let repo = repo.open();
let reference = match repo.try_find_reference("refs/stash") { 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 // No stash reference found
Ok(None) => return Some(0), Ok(_) => return Some(0),
Err(err) => { Err(err) => {
log::warn!("Error finding stash reference: {err}"); log::debug!("Error finding stash reference: {err}");
return None; return None;
} }
}; };
@ -272,7 +273,7 @@ fn get_stashed_count(repo: &context::Repo) -> Option<usize> {
Some(0) Some(0)
} }
Err(err) => { Err(err) => {
log::warn!("Error getting stash log: {err}"); log::debug!("Error getting stash log: {err}");
None None
} }
} }