aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov2019-07-16 01:27:19 +0300
committerJuri Linkov2019-07-16 01:27:19 +0300
commitcdec5a17fd148098e535b4168de0169082176bbd (patch)
treedc9b71991bdb7c1ca5b9f497f0167f9ddbf83243 /lisp
parent6253541c76a449780815f4a8fd75a9aa70b931ae (diff)
downloademacs-cdec5a17fd148098e535b4168de0169082176bbd.tar.gz
emacs-cdec5a17fd148098e535b4168de0169082176bbd.zip
* 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/vc/vc-git.el20
-rw-r--r--lisp/vc/vc.el18
2 files changed, 36 insertions, 2 deletions
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."