emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master cdec5a1: * lisp/vc/vc.el (vc-log-search): New comma


From: Juri Linkov
Subject: [Emacs-diffs] master cdec5a1: * lisp/vc/vc.el (vc-log-search): New command (bug#36644).
Date: Mon, 15 Jul 2019 18:27:25 -0400 (EDT)

branch: master
commit cdec5a17fd148098e535b4168de0169082176bbd
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    * lisp/vc/vc.el (vc-log-search): New command (bug#36644).
    
    * lisp/vc/vc-git.el (vc-git-log-search): New function.
    (vc-git-log-view-mode): Check vc-log-view-type for log-search.
---
 etc/NEWS          |  8 ++++++++
 lisp/vc/vc-git.el | 20 ++++++++++++++++++--
 lisp/vc/vc.el     | 18 ++++++++++++++++++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index edba159..76ea1df 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -695,6 +695,14 @@ buffers will delete the marked files (or if no files are 
marked, the
 file under point).  This command does not notify the VC backend, and
 is mostly useful for unregistered files.
 
+*** New command 'vc-log-search' asks for a pattern string, searches
+it in the revision log, and displays matched log entries in the
+log buffer.  For example, 'M-x vc-log-search RET bug#36644 RET'
+displays all entries whose log messages match the bug number.
+With a prefix argument asks for a command, so for example,
+'C-u M-x vc-log-search RET git log -1 f302475 RET' will display
+just one log entry found by its revision number.
+
 ** Diff mode
 +++
 *** Hunks are now automatically refined by font-lock.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 8b82856..5b61a7b 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1073,6 +1073,22 @@ If LIMIT is a revision string, use it as an 
end-revision."
                        "@{upstream}"
                      remote-location))))
 
+(defun vc-git-log-search (buffer pattern)
+  (let ((args `("log" "--no-color" "-i"
+                ,(format "--grep=%s"
+                         (or (and pattern (shell-quote-argument pattern))
+                             "")))))
+    (when current-prefix-arg
+      (setq args (cdr (split-string
+                      (read-shell-command
+                        "Search log with command: "
+                        (format "%s %s" vc-git-program
+                                (mapconcat 'identity args " "))
+                        'vc-git-history)
+                      " " t))))
+    (vc-setup-buffer buffer)
+    (apply 'vc-git-command buffer 'async nil args)))
+
 (defun vc-git-mergebase (rev1 &optional rev2)
   (unless rev2 (setq rev2 "HEAD"))
   (string-trim-right (vc-git--run-command-string nil "merge-base" rev1 rev2)))
@@ -1089,7 +1105,7 @@ If LIMIT is a revision string, use it as an end-revision."
   (set (make-local-variable 'log-view-file-re) regexp-unmatchable)
   (set (make-local-variable 'log-view-per-file-logs) nil)
   (set (make-local-variable 'log-view-message-re)
-       (if (not (eq vc-log-view-type 'long))
+       (if (not (memq vc-log-view-type '(long log-search)))
           (cadr vc-git-root-log-format)
         "^commit *\\([0-9a-z]+\\)"))
   ;; Allow expanding short log entries.
@@ -1098,7 +1114,7 @@ If LIMIT is a revision string, use it as an end-revision."
     (set (make-local-variable 'log-view-expanded-log-entry-function)
         'vc-git-expanded-log-entry))
   (set (make-local-variable 'log-view-font-lock-keywords)
-       (if (not (eq vc-log-view-type 'long))
+       (if (not (memq vc-log-view-type '(long log-search)))
           (list (cons (nth 1 vc-git-root-log-format)
                       (nth 2 vc-git-root-log-format)))
         (append
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index eb6d6d3..a68beb5 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -337,6 +337,10 @@
 ;;   Insert in BUFFER the revision log for the changes that will be
 ;;   received when performing a pull operation from REMOTE-LOCATION.
 ;;
+;; - log-search (pattern)
+;;
+;;   Search for string PATTERN in the revision log.
+;;
 ;; - log-view-mode ()
 ;;
 ;;   Mode to use for the output of print-log.  This defaults to
@@ -2527,6 +2531,20 @@ When called interactively with a prefix argument, prompt 
for REMOTE-LOCATION."
                                    "*vc-outgoing*" 'log-outgoing)))
 
 ;;;###autoload
+(defun vc-log-search (pattern)
+  "Search a log of changes for PATTERN string.
+Display all entries that match log messages in long format.
+With a prefix argument, ask for a command to run that will output
+log entries."
+  (interactive (list (unless current-prefix-arg
+                       (read-regexp "Search log with pattern: "))))
+  (let ((backend (vc-deduce-backend)))
+    (unless backend
+      (error "Buffer is not version controlled"))
+    (vc-incoming-outgoing-internal backend pattern
+                                   "*vc-search-log*" 'log-search)))
+
+;;;###autoload
 (defun vc-log-mergebase (_files rev1 rev2)
   "Show a log of changes between the merge base of REV1 and REV2 revisions.
 The merge base is a common ancestor between REV1 and REV2 revisions."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]