summaryrefslogtreecommitdiff
path: root/lisp/km-magit.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-01-26 23:04:57 -0500
committerKyle Meyer <kyle@kyleam.com>2017-01-26 23:04:57 -0500
commite2551619ece269cf0e425f6f619d39856c8aa255 (patch)
treef3bcc2c358f9d55723fb056b6d191264500a3d87 /lisp/km-magit.el
parent6ee5760ad42d795d8d451632ae18d1666a6042e2 (diff)
downloademacs.d-e2551619ece269cf0e425f6f619d39856c8aa255.tar.gz
magit: Add a log dwim command
Diffstat (limited to 'lisp/km-magit.el')
-rw-r--r--lisp/km-magit.el23
1 files changed, 23 insertions, 0 deletions
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