Skip to content

Commit

Permalink
Fix the count in user-specified counsel-git-grep
Browse files Browse the repository at this point in the history
* counsel.el (counsel--gg-count): Generate the count command from
`counsel-git-grep-cmd' by replacing "--full-name" with "-c".

Re #244
  • Loading branch information
abo-abo committed Oct 19, 2015
1 parent e338785 commit 2ae7d74
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions counsel.el
Expand Up @@ -742,10 +742,17 @@ The libraries are offered from `load-path'."
"Quickly and asynchronously count the amount of git grep REGEX matches.
When NO-ASYNC is non-nil, do it synchronously."
(let ((default-directory counsel--git-grep-dir)
(cmd (format "git grep -i -c '%s' | sed 's/.*:\\(.*\\)/\\1/g' | awk '{s+=$1} END {print s}'"
(replace-regexp-in-string
"-" "\\\\-"
(replace-regexp-in-string "'" "''" regex))))
(cmd
(concat
(format
(replace-regexp-in-string
"--full-name" "-c"
counsel-git-grep-cmd)
;; "git grep -i -c '%s'"
(replace-regexp-in-string
"-" "\\\\-"
(replace-regexp-in-string "'" "''" regex)))
" | sed 's/.*:\\(.*\\)/\\1/g' | awk '{s+=$1} END {print s}'"))
(counsel-ggc-process " *counsel-gg-count*"))
(if no-async
(string-to-number (shell-command-to-string cmd))
Expand Down

0 comments on commit 2ae7d74

Please sign in to comment.