delta
delta copied to clipboard
🐛 delta replaces characters when used with `git grep --name-only`
So far it's only the - character that I've noticed.
| thing | value |
|---|---|
| delta | 0.18.2 |
| git | 2.39.5 |
| LANG | en_US.UTF-8 |
| PRETTY_NAME | Debian GNU/Linux 12 (bookworm) |
Raw output:
$ git --no-pager grep --name-only airflow:CreateCli
dev-account/policy.tf
Delta output:
$ git config pager.grep
delta
$ git grep --name-only airflow:CreateCli
dev:account/policy.tf
Delta output without --name-only
$ git grep airflow:CreateCli
dev-account/policy.tf: "airflow:CreateCliToken",
I just found the same thing here. At first I thought it was a Git bug, but I inspected it and it only happens when using delta as pager.
It also happens when git grepping binary files
Hi, thanks for the report. Perhaps delta can be modified to behave differently when --name-only is in effect; either by inferring that from the output, or by inspecting the calling process command line (we are already forced to do this in some other situations, so there are utilities to do it performantly).
In general, traditional grep output (i.e. not the sort produced by --name-only) is subject to inevitable parse ambiguities involving the separator characters used. So, I think that's what's going on here, but like I say, if we actually know we're working with --name-only then we shouldn't be getting it wrong! Also not claiming that delta's regexps are optimal -- there are lots of tests and we'd welcome improvements to them -- I'm just claiming that there's not a perfect solution.
I know that git grep does things that ripgrep cannot but, if it is an option, then do consider rg --json since then there are no parse ambiguities.