fix(git): stop reporting staged files when nothing was staged - #4764
Open
ConnorMoss02 wants to merge 2 commits into
Open
fix(git): stop reporting staged files when nothing was staged#4764ConnorMoss02 wants to merge 2 commits into
ConnorMoss02 wants to merge 2 commits into
Conversation
git_add returned the constant "Files staged successfully" regardless of what the index took. `git add` exits 0 when it stages nothing, so two callers got a success they could not check: - files: [] runs `git add --` with no pathspec, a no-op - files: ["."] on a tree with no changes stages nothing Paired with git_commit, an agent could stage nothing, commit nothing, and report the work as committed. Rejects an empty list at the schema and in the function, and reads the outcome back from the index instead of assuming it from the exit status. The success string is unchanged when it is true.
Index entry keys are PathLike, and a diff entry can leave either path unset, so the helper returned list[PathLike] and list[str | None] where list[str] was declared.
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.
Closes #4763
git_addreturns the constantFiles staged successfullyregardless of what the index took.git addexits 0 when it stages nothing, so two calls report success having done nothing:files: []runsgit add --with no pathspec, a no-op. The schema put no minimum on the list.files: ["."]on a tree with no changes stages nothing.A nonexistent path is unaffected —
git add -- nope.txtalready raises.Paired with #4762, an agent can stage nothing, commit nothing, and report the work as committed.
Fix
min_length=1) and in the function, since it can never stage anything.The success string is byte-identical when it is true, so callers matching on it are unaffected.
Tests
Three: the empty list rejected at the function and at the schema, and
["."]on an unchanged tree no longer claiming success. All three fail with the source change reverted. 50 passed insrc/git.