diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index 136419a35ae1ac656c1fe82a3fb63019b8f74518..f07c7be14cdf2d0ac5505b6fdab396c01dc5d85e 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -254,11 +254,12 @@ impl GitRepository for FakeGitRepository { ); } - let mut snapshot = None; - for _ in 0..pop_count { - snapshot = state.commit_history.pop(); - } - let snapshot = snapshot.expect("pop_count validated above"); + let target_index = state.commit_history.len() - pop_count; + state.commit_history.truncate(target_index + 1); + let snapshot = state + .commit_history + .pop() + .expect("pop_count validated above"); match mode { ResetMode::Soft => {