summaryrefslogtreecommitdiff
path: root/lisp/vc/vc-git.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2019-03-25 23:45:31 +0200
committerJuri Linkov <juri@linkov.net>2019-03-25 23:45:31 +0200
commitd43af7b64bd22724e5e9a624bcc06b4ed28faf73 (patch)
treec67ea4d1d90dca703dccfa0106c181dc109d676e /lisp/vc/vc-git.el
parentdb53731c5f7e11240244161623b82b55cf303043 (diff)
downloademacs-d43af7b64bd22724e5e9a624bcc06b4ed28faf73.tar.gz
* lisp/vc/vc.el (vc-diff-mergebase, vc-log-mergebase): New commands.
* lisp/vc/vc-git.el (vc-git-mergebase): New function. (vc-git-print-log): Interpret string value of arg LIMIT as an end-revision. * lisp/vc/vc-hooks.el (vc-prefix-map): Bind 'vc-log-mergebase' to 'C-x v M L', and 'vc-diff-mergebase' to 'C-x v M D'. (Bug#33950)
Diffstat (limited to 'lisp/vc/vc-git.el')
-rw-r--r--lisp/vc/vc-git.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 0f8c9c836ce..a921ff1bb88 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -101,6 +101,7 @@
(eval-when-compile
(require 'cl-lib)
+ (require 'subr-x) ; for string-trim-right
(require 'vc)
(require 'vc-dir))
@@ -1017,7 +1018,8 @@ This prompts for a branch to merge from."
If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'.
\(This requires at least Git version 1.5.6, for the --graph option.)
If START-REVISION is non-nil, it is the newest revision to show.
-If LIMIT is non-nil, show no more than this many entries."
+If LIMIT is a number, show no more than this many entries.
+If LIMIT is a revision string, use it as an end-revision."
(let ((coding-system-for-read
(or coding-system-for-read vc-git-log-output-coding-system)))
;; `vc-do-command' creates the buffer, but we need it before running
@@ -1045,8 +1047,14 @@ If LIMIT is non-nil, show no more than this many entries."
,(format "--pretty=tformat:%s"
(car vc-git-root-log-format))
"--abbrev-commit"))
- (when limit (list "-n" (format "%s" limit)))
- (when start-revision (list start-revision))
+ (when (numberp limit)
+ (list "-n" (format "%s" limit)))
+ (when start-revision
+ (if (and limit (not (numberp limit)))
+ (list (concat start-revision ".." (if (equal limit "")
+ "HEAD"
+ limit)))
+ (list start-revision)))
'("--")))))))
(defun vc-git-log-outgoing (buffer remote-location)
@@ -1077,6 +1085,10 @@ If LIMIT is non-nil, show no more than this many entries."
"@{upstream}"
remote-location))))
+(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)))
+
(defvar log-view-message-re)
(defvar log-view-file-re)
(defvar log-view-font-lock-keywords)
@@ -1093,7 +1105,7 @@ If LIMIT is non-nil, show no more than this many entries."
(cadr vc-git-root-log-format)
"^commit *\\([0-9a-z]+\\)"))
;; Allow expanding short log entries.
- (when (memq vc-log-view-type '(short log-outgoing log-incoming))
+ (when (memq vc-log-view-type '(short log-outgoing log-incoming mergebase))
(setq truncate-lines t)
(set (make-local-variable 'log-view-expanded-log-entry-function)
'vc-git-expanded-log-entry))