From 20d71cfdac79b115c1198f167d4549cb82a5bef2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 1 Apr 2026 11:31:11 -0400 Subject: [PATCH] Clarify FakeGitRepository reset with truncate+pop instead of loop Replace the obscure pop loop with truncate+pop to make the intent explicit: keep entries up to the target, then pop the target to use its contents. Identical behavior, clearer code. --- crates/fs/src/fake_git_repo.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 => {