[ai] Fix word-splitting in git status parsing#14
Conversation
WalkthroughThe change modifies the Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bashy (1)
34-35: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAhead/behind regex matches any line, not just the
##branch header.
[[ $line =~ behind ]]/[[ $line =~ ahead ]]run against every line in the loop, including file status lines. A tracked file whose name contains "ahead" or "behind" (e.g.ahead_calc.py) would falsely set the ahead/behind flag. Since this loop was just reworked to fix line-splitting issues, it's a good time to anchor the check to the branch header line.🔧 Proposed fix to scope the match to the `##` header line
- [[ $line =~ behind ]] && behind=1 - [[ $line =~ ahead ]] && ahead=1 + if [[ ${line:0:2} == '##' ]]; then + [[ $line =~ behind ]] && behind=1 + [[ $line =~ ahead ]] && ahead=1 + fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bashy` around lines 34 - 35, The ahead/behind detection in the loop is too broad because `[[ $line =~ behind ]]` and `[[ $line =~ ahead ]]` match any line, including file names and status lines. Update the matching logic in the `bashy` loop so the `behind` and `ahead` flags are only set when processing the `##` branch header line, using the existing line variable and the reworked line-splitting flow to keep the check scoped to the header.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@bashy`:
- Around line 34-35: The ahead/behind detection in the loop is too broad because
`[[ $line =~ behind ]]` and `[[ $line =~ ahead ]]` match any line, including
file names and status lines. Update the matching logic in the `bashy` loop so
the `behind` and `ahead` flags are only set when processing the `##` branch
header line, using the existing line variable and the reworked line-splitting
flow to keep the check scoped to the header.
|
Repo not maintained — closing per Pablo |
What: Fixed word-splitting bug in git status output parsing. Replaced for loop with while IFS= read -r to iterate lines instead of whitespace-split words.
Found by: Static analysis — unquoted variable in for-loop iterates over IFS-split words, not lines, causing incorrect porcelain status parsing.
Fix: Changed loop from for line in gitstatus to while IFS= read -r line with proper heredoc. Updated regex patterns to check both index (position 1) and working tree (position 2) columns in porcelain v1 format using substring checks.
Tested:
Summary by CodeRabbit