From 3b38cb0516c0560fd5f54de377c481b42ff28d5f Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 13 Sep 2018 01:09:53 +0300 Subject: [PATCH] * lisp/vc/vc-git.el (vc-git-grep): Set dir to default-directory when it's not available (like it's implemented in lgrep/rgrep) to prevent error in case of `C-u C-u vc-git-grep'. --- lisp/vc/vc-git.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 69d62957026..ca457fb3d1e 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1440,8 +1440,7 @@ This command shares argument histories with \\[rgrep] and \\[grep]." (cond ((equal current-prefix-arg '(16)) (list (read-from-minibuffer "Run: " "git grep" - nil nil 'grep-history) - nil)) + nil nil 'grep-history))) (t (let* ((regexp (grep-read-regexp)) (files (mapconcat #'shell-quote-argument @@ -1451,6 +1450,8 @@ This command shares argument histories with \\[rgrep] and \\[grep]." (list regexp files dir)))))) (require 'grep) (when (and (stringp regexp) (> (length regexp) 0)) + (unless (and dir (file-accessible-directory-p dir)) + (setq dir default-directory)) (let ((command regexp)) (if (null files) (if (string= command "git grep") -- 2.39.2