fix: handle backslashes in filenames in _forgit_worktree_changes#500
fix: handle backslashes in filenames in _forgit_worktree_changes#500
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded a new internal helper Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Git escapes backslashes with `git status` even when `core.quotepath=false` is set. Use `--porcelain -z` with `git status` as a more robust approach to fix this. Fixes wfxr#467
7a8e066 to
91c4645
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/working-tree-changes.test.sh (1)
29-68: Add a config-mode test forstatus.showUntrackedFiles=no.The helper explicitly depends on this config, but current tests only validate default behavior.
As per coding guidelines "Add or update tests for behavior changes, especially parsing, selection, and cross-shell integration".Suggested test case
+function test_forgit_worktree_changes_respects_show_untracked_no() { + local output + + git config status.showUntrackedFiles no + output=$(_forgit_worktree_changes) + + assert_not_contains "untracked_file.txt" "$output" + assert_not_contains 'untracked_with_\backslash' "$output" +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/working-tree-changes.test.sh` around lines 29 - 68, Add a new test to verify _forgit_worktree_changes respects git config status.showUntrackedFiles=no: create a test function (e.g., test_forgit_worktree_changes_respects_showUntrackedFiles_no) that sets the repo-local config (git config --local status.showUntrackedFiles no), calls _forgit_worktree_changes to capture output, asserts that untracked entries like "untracked_file.txt" and 'untracked_with_\backslash' are NOT present while keeping other behavior (modified files still present), and then restore or unset the config to avoid affecting other tests; reference _forgit_worktree_changes and use assert_not_contains/assert_contains as in the existing tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bin/git-forgit`:
- Around line 221-230: The current pipeline in bin/git-forgit uses color tokens
($changed, $unmerged, $untracked) to filter git status output, which breaks when
multiple color keys map to the same ANSI code; replace the grep-based color
filtering with a porcelain-status parsing step that examines the XY status codes
instead. Specifically, after the git -c ... status --porcelain -zs output (the
pipeline that currently goes into tr '\0' '\n'), drop the grep -F -e "$changed"
-e "$unmerged" -e "$untracked" and instead pipe into an awk filter that parses
the leading two-character status (substr($0,1,2)) and only prints lines where
the worktree status (second char, Y) is non-space (Y != " ") or where the entry
is untracked (first char == "?"), ensuring staged-only entries (X != " " and Y
== " ") are excluded; leave the final sed -E
's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/' intact to format the output.
---
Nitpick comments:
In `@tests/working-tree-changes.test.sh`:
- Around line 29-68: Add a new test to verify _forgit_worktree_changes respects
git config status.showUntrackedFiles=no: create a test function (e.g.,
test_forgit_worktree_changes_respects_showUntrackedFiles_no) that sets the
repo-local config (git config --local status.showUntrackedFiles no), calls
_forgit_worktree_changes to capture output, asserts that untracked entries like
"untracked_file.txt" and 'untracked_with_\backslash' are NOT present while
keeping other behavior (modified files still present), and then restore or unset
the config to avoid affecting other tests; reference _forgit_worktree_changes
and use assert_not_contains/assert_contains as in the existing tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c9e6d183-b12f-417a-927d-6a6a7cc6b7e7
📒 Files selected for processing (2)
bin/git-forgittests/working-tree-changes.test.sh
Check list
Description
Fixes #467
Type of change
Test environment
Summary by CodeRabbit
Bug Fixes
Improvements
Tests