diff options
author | David Knaack <davidkna@users.noreply.github.com> | 2023-12-16 16:58:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-16 16:58:45 +0100 |
commit | 00d3dc86a21d11aede96f81ffbe49babe487984e (patch) | |
tree | fe2b857e34fa2e7a77909bb378598ed8a36b5cc4 /src | |
parent | e79014a99f36e25d7223ef78dac95c72aded7446 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/git_status.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs index 614e6f66a..d1dd4c098 100644 --- a/src/modules/git_status.rs +++ b/src/modules/git_status.rs @@ -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 } } |