From 6ddc4972208f923e9439c36e512286a89530df38 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 28 Apr 2018 21:48:33 -0400 Subject: km/magit-log-dwim: Handle merges in revision buffers --- lisp/km-magit.el | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'lisp/km-magit.el') diff --git a/lisp/km-magit.el b/lisp/km-magit.el index b311962..d515acb 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -636,22 +636,26 @@ argument. Interactively, this can be accessed using the command (defun km/magit-log-dwim (&optional args files) (interactive (magit-log-arguments)) (let ((range - (magit-section-case - ((unpushed unpulled) - (magit-section-value it)) - (tag - (concat (magit-section-value it) "..")) - (branch - (let ((current (magit-get-current-branch)) - (atpoint (magit-section-value it)) - (upstream (magit-get-upstream-branch)) - (push (magit-get-push-branch))) - (cond ((equal atpoint current) - (and upstream (concat upstream ".."))) - ((equal atpoint push) - (concat push "..")) - (t - (concat ".." atpoint)))))))) + (or (magit-section-case + ((unpushed unpulled) + (magit-section-value it)) + (tag + (concat (magit-section-value it) "..")) + (branch + (let ((current (magit-get-current-branch)) + (atpoint (magit-section-value it)) + (upstream (magit-get-upstream-branch)) + (push (magit-get-push-branch))) + (cond ((equal atpoint current) + (and upstream (concat upstream ".."))) + ((equal atpoint push) + (concat push "..")) + (t + (concat ".." atpoint)))))) + (--when-let (and (derived-mode-p 'magit-revision-mode) + (car magit-refresh-args)) + (and (magit-rev-verify (concat it "^2")) + (concat it "^-1")))))) (if range (magit-log (list range) args files) (call-interactively #'magit-log)))) -- cgit v1.2.3