Magit-grep how to include or exclude file extensions?

I would like to give some options for magit-grep

running with the foo parameter results in

 git --no-pager grep -n foo 

I would give him options

 git --no-pager grep -n foo (options to include *.html and exclude *.py, etc) 

It should not be magit-grep, what is the best git grep solution in emacs?


Magit-grep

 (magit-define-command grep (&optional pattern) (interactive) (let ((pattern (or pattern (read-string "git grep: " (shell-quote-argument (grep-tag-default)))))) (with-current-buffer (generate-new-buffer "*Magit Grep*") (let ((default-directory (magit-get-top-dir))) (insert magit-git-executable " " (mapconcat 'identity magit-git-standard-options " ") " grep -n " (shell-quote-argument pattern) "\n\n") (magit-git-insert (list "grep" "--line-number" pattern)) (grep-mode) (pop-to-buffer (current-buffer)))))) 
+4
source share
2 answers

I removed magit-grep as it was just a badly distorted version of rgrep . vc-git-grep is actually an improvement, so you should use this. (Currently, magit-grep is defined as an alias for the vc command, so as not to disturb anyone who has previously used the magnet option. The classic case is β€œadding functions, looking at what already exists elsewhere, and then deleting our code” :-)

+4
source

One option is a combination of og git-grep and git-ls-files :

 git grep ... `git ls-files | grep -- '\.html$'` 

But this only works if the output of git-ls-files does not exceed the maximum command line size on your system (which is a couple of 100 KB on modern systems).

+2
source

Source: https://habr.com/ru/post/1492192/


All Articles