From e2551619ece269cf0e425f6f619d39856c8aa255 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 26 Jan 2017 23:04:57 -0500 Subject: magit: Add a log dwim command --- lisp/km-magit.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lisp') diff --git a/lisp/km-magit.el b/lisp/km-magit.el index d8972ba..0c4a344 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -623,6 +623,29 @@ argument. Interactively, this can be accessed using the command 'git-commit-flyspell-verify) (turn-on-flyspell)) +(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)))))))) + (if range + (magit-log (list range) args files) + (call-interactively #'magit-log)))) + ;;; Git Rebase mode -- cgit v1.2.3