Skip to content

Support git's mnemonic diff prefixes in DiffParser - #245

Merged
lyrixx merged 1 commit into
mainfrom
worktree-issue-114-mnemonic-prefix
Sep 7, 2026
Merged

Support git's mnemonic diff prefixes in DiffParser#245
lyrixx merged 1 commit into
mainfrom
worktree-issue-114-mnemonic-prefix

Conversation

@lyrixx

@lyrixx lyrixx commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

  • DiffParser hardcoded the a//b/ prefixes in the diff --git header regexp, but git's diff.mnemonicPrefix option (enabled by tools like GrumPHP) replaces them with context-specific single-letter prefixes (c/ commit, i/ index, o/ object, w/ work tree), causing No match for regexp /diff --git (a\/.*) (b\/.*)\n/.
  • The regexp now accepts any single non-slash character as the prefix, matching git's actual mnemonic-prefix behavior.

Fixes #114

Test plan

  • Added DiffTest::testMnemonicPrefix reproducing the c//i/ case from the issue
  • Full test suite passes (vendor/bin/phpunit)
  • php-cs-fixer and phpstan clean

diff.mnemonicPrefix replaces the default "a/"/"b/" prefixes with
context-specific ones ("c/", "i/", "o/", "w/"), which DiffParser's
regexp didn't account for, causing a RuntimeException for tools like
GrumPHP that enable it.

Fixes #114
@lyrixx
lyrixx merged commit 9bdf6bd into main Sep 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

No match for regexp /diff --git (a\/.*) (b\/.*)\n/

1 participant