Skip to content

Fix path parsing for git grep filename-only output with hyphens#2185

Open
momomuchu wants to merge 1 commit into
dandavison:mainfrom
momomuchu:fix/grep-hyphen-path-parse-1869
Open

Fix path parsing for git grep filename-only output with hyphens#2185
momomuchu wants to merge 1 commit into
dandavison:mainfrom
momomuchu:fix/grep-hyphen-path-parse-1869

Conversation

@momomuchu

Copy link
Copy Markdown

Fixes #1869

git grep -l/-L/--name-only/--files-with-matches/--files-without-match emit a bare path per line, no separator, no code. parse_grep_line was still running that bare path through the path:line:code separator regexes, so a hyphen in the path got misread as the nomatch separator and rewritten as a colon.

Detects filename-only output from the git grep command line and passes the line through as a plain path instead.

Same root cause as #1674 (git grep -l), so this should fix that one too.

parse_grep_line applied the path:line:code separator regexes even when
git grep was run with -l, -L, --name-only, --files-with-matches or
--files-without-match. Those modes emit a bare path with no separator,
so a hyphen in the path (e.g. dev-account/policy.tf) got misread as the
nomatch separator and rewritten, corrupting the path.

Detect filename-only output from the git grep command line and pass
the line through as a plain path instead of running it through the
separator-guessing regexes.

Fixes dandavison#1869
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.

🐛 delta replaces characters when used with git grep --name-only

1 participant