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

counsel-git-grep : how to specify "." or "*" in search pattern #876

Closed
shalin24 opened this Issue Feb 3, 2017 · 7 comments

Comments

Projects
None yet
2 participants
@shalin24

shalin24 commented Feb 3, 2017

May be I am missing something basic, but I can't figure out how to specify "." or "*" in the search pattern while using counsel-git-grep.

In swiper, I am able to use "." to specify "." and "*" to specify "*". Should the same thing work for counsel-git-grep also? Is there another way to specify these characters in the search pattern?

@shalin24 shalin24 changed the title from counsel-git-grep : not able to specify "." or "*" in search pattern to counsel-git-grep : how to specify "." or "*" in search pattern Feb 3, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Feb 4, 2017

You have to escape them: \. or \*.

@shalin24

This comment has been minimized.

shalin24 commented Feb 4, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Feb 4, 2017

Did you customize any setting for counsel-git-grep? It's pretty easy to mimic counsel-git-grep by typing the same command into the terminal.

@shalin24

This comment has been minimized.

shalin24 commented Feb 7, 2017

I have not customized any settings for counsel-git-grep. Here is what I have:

counsel-git-grep-cmd-default
git --no-pager grep --full-name -n --no-color -i -e %S

counsel-git-grep-cmd
git --no-pager grep --full-name -n --no-color -i -e %S

I tried counsel-git-grep for the patterns abc.sv and abc\.sv, and this is what I see for the history:

counsel-git-grep-history
 (#("abc\\.sv" 0 7
   (ivy-index 0))
 #("abc.sv" 0 6
   (ivy-index 1))

I tried to mimic the greps in a terminal. Here is the output:

% git --no-pager grep --full-name -n --no-color -i -e 'abc.sv'
verif/lib/intf/spm_xfi_consume_ring_if.sv:25:// abc_sv
verif/lib/intf/spm_xfi_consume_ring_if.sv:26:// abc.sv

% git --no-pager grep --full-name -n --no-color -i -e 'abc\.sv'
verif/lib/intf/spm_xfi_consume_ring_if.sv:26:// abc.sv

% git --no-pager grep --full-name -n --no-color -i -e 'abc\\.sv'
%

So it looks like with counsel-git-grep, \ gets translated to \\.

Or am I missing something or doing something wrong?

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Feb 7, 2017

It seems I'm using a custom command myself. Can you try it with my setting:

(setq counsel-git-grep-cmd-default
      "git --no-pager grep --full-name -n --no-color -i -e '%s' -- './*' ':!*.htm'")
@shalin24

This comment has been minimized.

shalin24 commented Feb 7, 2017

That works. With your custom command, when I run counsel-git-grep, and type abc\.sv, the first line in the output is the git command being run, and it contains only one \, and the search results are as expected.

@abo-abo abo-abo closed this in 6e6738c Feb 8, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Feb 8, 2017

Fixed, thanks.

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