aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/vc/vc-git.el20
-rw-r--r--lisp/vc/vc.el18
3 files changed, 44 insertions, 2 deletions
diff --git a/etc/NEWS b/etc/NEWS
index edba159bd49..76ea1df8213 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -695,6 +695,14 @@ buffers will delete the marked files (or if no files are marked, the
695file under point). This command does not notify the VC backend, and 695file under point). This command does not notify the VC backend, and
696is mostly useful for unregistered files. 696is mostly useful for unregistered files.
697 697
698*** New command 'vc-log-search' asks for a pattern string, searches
699it in the revision log, and displays matched log entries in the
700log buffer. For example, 'M-x vc-log-search RET bug#36644 RET'
701displays all entries whose log messages match the bug number.
702With a prefix argument asks for a command, so for example,
703'C-u M-x vc-log-search RET git log -1 f302475 RET' will display
704just one log entry found by its revision number.
705
698** Diff mode 706** Diff mode
699+++ 707+++
700*** Hunks are now automatically refined by font-lock. 708*** Hunks are now automatically refined by font-lock.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 8b828563325..5b61a7b4bc2 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."
1073 "@{upstream}" 1073 "@{upstream}"
1074 remote-location)))) 1074 remote-location))))
1075 1075
1076(defun vc-git-log-search (buffer pattern)
1077 (let ((args `("log" "--no-color" "-i"
1078 ,(format "--grep=%s"
1079 (or (and pattern (shell-quote-argument pattern))
1080 "")))))
1081 (when current-prefix-arg
1082 (setq args (cdr (split-string
1083 (read-shell-command
1084 "Search log with command: "
1085 (format "%s %s" vc-git-program
1086 (mapconcat 'identity args " "))
1087 'vc-git-history)
1088 " " t))))
1089 (vc-setup-buffer buffer)
1090 (apply 'vc-git-command buffer 'async nil args)))
1091
1076(defun vc-git-mergebase (rev1 &optional rev2) 1092(defun vc-git-mergebase (rev1 &optional rev2)
1077 (unless rev2 (setq rev2 "HEAD")) 1093 (unless rev2 (setq rev2 "HEAD"))
1078 (string-trim-right (vc-git--run-command-string nil "merge-base" rev1 rev2))) 1094 (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."
1089 (set (make-local-variable 'log-view-file-re) regexp-unmatchable) 1105 (set (make-local-variable 'log-view-file-re) regexp-unmatchable)
1090 (set (make-local-variable 'log-view-per-file-logs) nil) 1106 (set (make-local-variable 'log-view-per-file-logs) nil)
1091 (set (make-local-variable 'log-view-message-re) 1107 (set (make-local-variable 'log-view-message-re)
1092 (if (not (eq vc-log-view-type 'long)) 1108 (if (not (memq vc-log-view-type '(long log-search)))
1093 (cadr vc-git-root-log-format) 1109 (cadr vc-git-root-log-format)
1094 "^commit *\\([0-9a-z]+\\)")) 1110 "^commit *\\([0-9a-z]+\\)"))
1095 ;; Allow expanding short log entries. 1111 ;; Allow expanding short log entries.
@@ -1098,7 +1114,7 @@ If LIMIT is a revision string, use it as an end-revision."
1098 (set (make-local-variable 'log-view-expanded-log-entry-function) 1114 (set (make-local-variable 'log-view-expanded-log-entry-function)
1099 'vc-git-expanded-log-entry)) 1115 'vc-git-expanded-log-entry))
1100 (set (make-local-variable 'log-view-font-lock-keywords) 1116 (set (make-local-variable 'log-view-font-lock-keywords)
1101 (if (not (eq vc-log-view-type 'long)) 1117 (if (not (memq vc-log-view-type '(long log-search)))
1102 (list (cons (nth 1 vc-git-root-log-format) 1118 (list (cons (nth 1 vc-git-root-log-format)
1103 (nth 2 vc-git-root-log-format))) 1119 (nth 2 vc-git-root-log-format)))
1104 (append 1120 (append
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index eb6d6d331fe..a68beb5e505 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -337,6 +337,10 @@
337;; Insert in BUFFER the revision log for the changes that will be 337;; Insert in BUFFER the revision log for the changes that will be
338;; received when performing a pull operation from REMOTE-LOCATION. 338;; received when performing a pull operation from REMOTE-LOCATION.
339;; 339;;
340;; - log-search (pattern)
341;;
342;; Search for string PATTERN in the revision log.
343;;
340;; - log-view-mode () 344;; - log-view-mode ()
341;; 345;;
342;; Mode to use for the output of print-log. This defaults to 346;; 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."
2527 "*vc-outgoing*" 'log-outgoing))) 2531 "*vc-outgoing*" 'log-outgoing)))
2528 2532
2529;;;###autoload 2533;;;###autoload
2534(defun vc-log-search (pattern)
2535 "Search a log of changes for PATTERN string.
2536Display all entries that match log messages in long format.
2537With a prefix argument, ask for a command to run that will output
2538log entries."
2539 (interactive (list (unless current-prefix-arg
2540 (read-regexp "Search log with pattern: "))))
2541 (let ((backend (vc-deduce-backend)))
2542 (unless backend
2543 (error "Buffer is not version controlled"))
2544 (vc-incoming-outgoing-internal backend pattern
2545 "*vc-search-log*" 'log-search)))
2546
2547;;;###autoload
2530(defun vc-log-mergebase (_files rev1 rev2) 2548(defun vc-log-mergebase (_files rev1 rev2)
2531 "Show a log of changes between the merge base of REV1 and REV2 revisions. 2549 "Show a log of changes between the merge base of REV1 and REV2 revisions.
2532The merge base is a common ancestor between REV1 and REV2 revisions." 2550The merge base is a common ancestor between REV1 and REV2 revisions."