Repository navigation
loopguard: read the git subcommand after git's own options - #212
Open
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
Open
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
Conversation
git -C <dir> apply x.diff and git -C <dir> checkout -- f.py put the subcommand after git's own options (-C, -c, --no-pager, --git-dir ...). The shell-edit parser took the word right after git for the subcommand, so the patch was not counted as an edit and putting back a file the turn had edited was not counted either. Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
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.
Hi Aaron Li (@aaron-jx-li), one more from the shell-edit parser in
loopguard/shell_edits.py.Agents often run git with
-C <dir>instead of acd. The parser took the word right aftergitas the subcommand, so with any of git's own options in front it found nothing:git -C /w/repo apply /tmp/fix.diffwas not counted as an editgit -C repo checkout HEAD -- pkg/mod.pyandgit --git-dir=.git --work-tree . restore pkg/mod.pywere not counted as a write, and not as a revert either-c core.autocrlf=false,--no-pagerand friendsSo
TurnGuard.foldsaw no edit for those turns, and putting back a file the turn had edited did not count toward its churn.A small
_git_argshelper now skips git's own options (and the value of the ones that take the next word:-C,-c,--git-dir,--work-tree,--namespace,--config-env,--attr-source) before reading the subcommand._restoredand thegit applycheck both use it. Plaingit apply/git checkout --behave as before, and reads likegit -C repo difforgit -C repo log -- f.pystill count as nothing.Tests: new cases in
test_edits_made_through_the_shell_are_recognisedplus one throughTurnGuard.foldthat checks the patch and the revert are both counted. With the fix reverted, 5 of them fail.python -m pytest testspasses on Python 3.10 and 3.13 (902 passed, 16 skipped),experiments/testspasses, andscripts/dead_code.pyoutput is the same as on main.