diff options
| author | Juri Linkov | 2019-07-16 01:27:19 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-07-16 01:27:19 +0300 |
| commit | cdec5a17fd148098e535b4168de0169082176bbd (patch) | |
| tree | dc9b71991bdb7c1ca5b9f497f0167f9ddbf83243 | |
| parent | 6253541c76a449780815f4a8fd75a9aa70b931ae (diff) | |
| download | emacs-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.
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 20 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 18 |
3 files changed, 44 insertions, 2 deletions
| @@ -695,6 +695,14 @@ buffers will delete the marked files (or if no files are marked, the | |||
| 695 | file under point). This command does not notify the VC backend, and | 695 | file under point). This command does not notify the VC backend, and |
| 696 | is mostly useful for unregistered files. | 696 | is mostly useful for unregistered files. |
| 697 | 697 | ||
| 698 | *** New command 'vc-log-search' asks for a pattern string, searches | ||
| 699 | it in the revision log, and displays matched log entries in the | ||
| 700 | log buffer. For example, 'M-x vc-log-search RET bug#36644 RET' | ||
| 701 | displays all entries whose log messages match the bug number. | ||
| 702 | With 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 | ||
| 704 | just 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. | ||
| 2536 | Display all entries that match log messages in long format. | ||
| 2537 | With a prefix argument, ask for a command to run that will output | ||
| 2538 | log 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. |
| 2532 | The merge base is a common ancestor between REV1 and REV2 revisions." | 2550 | The merge base is a common ancestor between REV1 and REV2 revisions." |