diff options
-rw-r--r-- | init.el | 3 | ||||
-rw-r--r-- | lisp/km-magit.el | 23 |
2 files changed, 26 insertions, 0 deletions
@@ -1105,6 +1105,9 @@ (magit-change-popup-key 'magit-push-popup :action ?u ?U) + (magit-define-popup-action 'magit-log-popup + ?d "Log dwim" #'km/magit-log-dwim) + (magit-define-popup-action 'magit-merge-popup ?u "Merge upstream" #'km/magit-ff-merge-upstream) 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 |