Repository navigation
fix(gix): report cancellation and omit outcome when status::Iter is interrupted - #3242
Open
BHARATH CHANDRA VADDARAM (bharathvbcr) wants to merge 1 commit into
Open
BHARATH CHANDRA VADDARAM (bharathvbcr) wants to merge 1 commit into
BHARATH CHANDRA VADDARAM (bharathvbcr) wants to merge 1 commit into
Conversation
…nterrupted
Ensure interrupted gix::status::Iter emits Err(cancelled("Interrupted")) in both parallel and non-parallel paths and leaves Iter::into_outcome() empty instead of silently ending iteration with None or returning a partial Outcome. Update docstrings on should_interrupt_shared and should_interrupt_owned and add regression tests.
Assisted-by: Antigravity
Contributor
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
|
Turns out that if the dirwalk gets interrupted, it just aborts, which will trickle up to the caller. Of course, that could be fixed, but it feels more straightforward to just abort on interrupts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: This pull request was authored and locally tested by an AI coding assistant acting at
@bharathvbcr's request. I am speaking only for my own analysis and the local checks listed below, and make no claim that@bharathvbcrhas personally reviewed or tested this code.Motivation
Discovered while integrating
gix::Repository::status()into GitPulse (a desktop Git client replacing spawnedgit statusprocesses with in-processgixstatus, wired with per-request cancellation and timeouts). On a dirty repository, interruptingstatus::Iterviashould_interrupt_owned/should_interrupt_sharedcould silently terminate iteration withNoneand even populateIter::into_outcome()withSome(Outcome), making a cancelled or timed-out status scan indistinguishable from a clean working tree unless callers re-checked their own interrupt flag afterward.Problem
In
gix/src/status/iter/mod.rs:parallelfeature (Iterator for Iter):RecvTimeoutError::Timeout, whenself.should_interrupt.load(Ordering::SeqCst)is true,next()returnedNoneinstead of yieldingSome(Err(cancelled("Interrupted").raise())), and leftself.rx_and_joinset so subsequentnext()calls would keep polling/detaching instead of staying terminated.rx.recv_timeout(...),should_interruptwas not checked.RecvTimeoutError::Disconnected, especially when the directory walk is disabled (UntrackedFiles::None) and the producer finishes withOk(out)quickly after interruption,next()storedself.out = Some(out)and returnedNoneeven thoughshould_interruptwas set — contradictingIter::into_outcome()'s doc comment ("Noneon error or if the iteration isn't complete").not(feature = "parallel")(Platform::into_iter):should_interruptbefore starting or afterindex_worktree_status(...)returned, so an interrupted serial status run populatediter.out = Some(out)and returnedOk(iter)with potentially partial results.Changes
gix/src/status/iter/mod.rs:should_interrupt.load(Ordering::SeqCst)at the start of eachnext()poll (clearingrx_and_join), onRecvTimeoutError::Timeout(clearingrx_and_join), and before settingself.outonRecvTimeoutError::Disconnected, yieldingSome(Err(cancelled("Interrupted").raise()))without populatingself.out.should_interrupt.load(Ordering::SeqCst)before starting and afterindex_worktree_status(...)in the non-parallelpath, returningErr(cancelled("Interrupted").raise()).gix/src/status/platform.rs:should_interrupt_shared/should_interrupt_owneddocs that interruption stops iteration with a cancellation error and leavesIter::into_outcome()empty.gix/tests/gix/status.rs:UntrackedFiles::Nonepre-interruption,UntrackedFiles::Filespre-interruption, and mid-iteration interruption acrossparalleland non-parallelconfigurations.Verification
All commands below were run in the shallow fork checkout on macOS after the final edit:
cargo fmt -p gix -- --check(passed)cargo clippy -p gix --tests --features status,parallel -- -D warnings(passed)cargo clippy -p gix --lib --no-default-features --features status,sha1 -- -D warnings(passed)cargo test -p gix --features status,parallel -- status(48 passed, 0 failed)cargo test -p gix --no-default-features --features status,sha1 -- status(46 passed, 0 failed)cargo test -p gitoxide-core -- status(compiled and ran with 0 failures; status submodule filters 0 unit tests)