Fix off-by-one in FakeGitRepository::reset truncation

Richard Feldman created

The truncate(target_index + 1) call was a no-op when pop_count == 1
because target_index was len-1, so truncate(len) kept all elements.
This meant subsequent resets kept returning the same commit.

Fix: read the snapshot at target_index first, then truncate to
target_index (removing the consumed entry).

Change summary

crates/fs/src/fake_git_repo.rs | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

Detailed changes

crates/fs/src/fake_git_repo.rs 🔗

@@ -255,12 +255,8 @@ impl GitRepository for FakeGitRepository {
             }
 
             let target_index = state.commit_history.len() - pop_count;
-            state.commit_history.truncate(target_index + 1);
-            let snapshot = state
-                .commit_history
-                .last()
-                .expect("pop_count validated above")
-                .clone();
+            let snapshot = state.commit_history[target_index].clone();
+            state.commit_history.truncate(target_index);
 
             match mode {
                 ResetMode::Soft => {