Skip to content

revert: undo backslash filename handling in _forgit_worktree_changes#505

Open
sandr01d wants to merge 1 commit intowfxr:mainfrom
sandr01d:revert-backslash-fix
Open

revert: undo backslash filename handling in _forgit_worktree_changes#505
sandr01d wants to merge 1 commit intowfxr:mainfrom
sandr01d:revert-backslash-fix

Conversation

@sandr01d
Copy link
Copy Markdown
Collaborator

@sandr01d sandr01d commented Mar 29, 2026

Check list

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have added unit tests for my code
  • I have made corresponding changes to the documentation

Description

Reverts commmit 2c17635, because it introduced a regression on older git versions where _forgit_add no longer showed untracked files.
Closes #503

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Test
  • Documentation change

Test environment

  • Shell
    • bash
    • zsh
    • fish
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Summary by CodeRabbit

  • Changes
    • Modified how working tree status information is processed and displayed.
    • Updated filename handling behavior for certain special characters.

Reverts commmit 2c17635, because it
introduced a regression on older git versions where `_forgit_add` no
longer showed untracked files.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fcdd4a2b-3d72-4947-a17a-b80a88c6df9c

📥 Commits

Reviewing files that changed from the base of the PR and between d4bece4 and 3f636c1.

📒 Files selected for processing (2)
  • bin/git-forgit
  • tests/working-tree-changes.test.sh
💤 Files with no reviewable changes (1)
  • tests/working-tree-changes.test.sh

📝 Walkthrough

Walkthrough

Modified _forgit_worktree_changes function to process git status output differently: replaced NUL-delimited porcelain format with simple -s format and added core.quotePath=false configuration. Removed associated test for backslash-containing filenames.

Changes

Cohort / File(s) Summary
Git status output handling
bin/git-forgit
Changed status --porcelain -zs with NUL-to-newline conversion to status -s with core.quotePath=false, simplifying output processing pipeline.
Test cleanup
tests/working-tree-changes.test.sh
Removed fixture creation for untracked_with_\backslash and deleted corresponding test case test_forgit_worktree_changes_supports_backslashes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • wfxr
  • cjappl
  • carlfriedrich

Poem

🐰 A fix for the status quo!
No more -z and tr in the flow,
Simple -s now leads the way,
Untracked files bright as day,
On macOS, no more foes to know! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: reverting backslash filename handling in _forgit_worktree_changes, which aligns with the changeset modifications.
Description check ✅ Passed The description includes the rationale (regression on older Git versions), mentions the linked issue (#503), and specifies the bug fix type, though test environment checkboxes remain unchecked.
Linked Issues check ✅ Passed The PR successfully addresses issue #503 by reverting the problematic commit that caused the -z flag regression, restoring untracked file visibility on older Git versions like Apple Git 2.50.1.
Out of Scope Changes check ✅ Passed All changes are in-scope: modifications to _forgit_worktree_changes function and removal of related test fixture and test case directly address the regression described in issue #503.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Owner

@wfxr wfxr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can avoid the full revert here and keep the backslash fix from 2c17635.

Instead of switching _forgit_worktree_changes() back to git status -s, could we keep the current git ... status --porcelain -zs ... | tr '\0' '\n' pipeline and add a small fallback before the grep?

Concretely, we could normalize uncolored ?? lines to use color.status.untracked, and then continue with the existing grep / sed pipeline unchanged.

That should preserve both behaviors:

  • untracked files remain visible on older Git versions
  • filenames containing backslashes continue to work correctly

This seems preferable to reintroducing #467 and dropping its test coverage.

Something along these lines, for example:

git ... status --porcelain -zs --untracked=... |
    tr '\0' '\n' |
    _forgit_restore_untracked_color |
    grep -F -e "$changed" -e "$unmerged" -e "$untracked" |
    sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1]  \2/'

where _forgit_restore_untracked_color only patches plain ?? lines and leaves already-colorized output untouched.

@sandr01d
Copy link
Copy Markdown
Collaborator Author

That sounds like a good idea. However, I currently lack the time to implement this before the next monthly release, which is why I opted for the revert first and wanted to implement a proper fix later. If you do have the time, please open a PR and I'll do my best to review it in time - otherwise I would like to merge this one instead of releasing a broken forgit version.

@wfxr
Copy link
Copy Markdown
Owner

wfxr commented Mar 31, 2026

That sounds like a good idea. However, I currently lack the time to implement this before the next monthly release, which is why I opted for the revert first and wanted to implement a proper fix later. If you do have the time, please open a PR and I'll do my best to review it in time - otherwise I would like to merge this one instead of releasing a broken forgit version.

No problem, that sounds reasonable. I’ll open a PR for the fallback approach shortly and we can see if it can make it in before the release.

EDIT

PTAL #506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

forgit::add no longer shows untracked files

2 participants