Skip to content

Commit

Permalink
ensure we only proceed if the returned reference has the expected name
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkna committed Nov 7, 2023
1 parent 56edea1 commit b7bed88
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/modules/git_status.rs
Expand Up @@ -251,9 +251,10 @@ 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::debug!("Error finding stash reference: {err}");

Check warning on line 259 in src/modules/git_status.rs

View check run for this annotation

Codecov / codecov/patch

src/modules/git_status.rs#L259

Added line #L259 was not covered by tests
return None;
Expand Down

0 comments on commit b7bed88

Please sign in to comment.