Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ccosby opened this issue Sep 27, 2024 · 2 comments
Open

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

ccosby opened this issue Sep 27, 2024 · 2 comments

Comments

@ccosby
Copy link

ccosby commented Sep 27, 2024

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",
@lucasoshiro
Copy link

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

@dandavison
Copy link
Owner

dandavison commented Oct 17, 2024

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.

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

No branches or pull requests

3 participants