diff options
author | Kyle Meyer <kyle@kyleam.com> | 2017-01-26 23:04:57 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2017-01-26 23:04:57 -0500 |
commit | e2551619ece269cf0e425f6f619d39856c8aa255 (patch) | |
tree | f3bcc2c358f9d55723fb056b6d191264500a3d87 | |
parent | 6ee5760ad42d795d8d451632ae18d1666a6042e2 (diff) | |
download | emacs.d-e2551619ece269cf0e425f6f619d39856c8aa255.tar.gz |
magit: Add a log dwim command
-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 |