[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit c33ed664e6 4/4: magit-log-related: New command
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit c33ed664e6 4/4: magit-log-related: New command |
Date: |
Thu, 20 Jan 2022 11:58:35 -0500 (EST) |
branch: elpa/git-commit
commit c33ed664e6d673368df6be43d0656bc2d64700e3
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-log-related: New command
---
docs/magit.org | 7 +++++++
docs/magit.texi | 12 ++++++++++--
lisp/magit-log.el | 32 ++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/docs/magit.org b/docs/magit.org
index d951258afe..1634c05915 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -2595,6 +2595,13 @@ The log transient also features several reflog commands.
See [[*Reflog]].
Show log for ~HEAD~.
+- Key: l u (magit-log-related) ::
+
+ Show log for the current branch, its upstream and its push target.
+ When the upstream is a local branch, then also show its own
+ upstream. When ~HEAD~ is detached, then show log for that, the
+ previously checked out branch and its upstream and push-target.
+
- Key: l o (magit-log-other) ::
Show log for one or more revs read from the minibuffer. The user
diff --git a/docs/magit.texi b/docs/magit.texi
index 7e6f49b6f4..b874ea2577 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -31,7 +31,7 @@ General Public License for more details.
@finalout
@titlepage
@title Magit User Manual
-@subtitle for version v3.3.0-99-g2914b9202+1
+@subtitle for version v3.3.0-100-g5f23bcd77+1
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
@@ -53,7 +53,7 @@ directly from within Emacs. While many fine Git clients
exist, only
Magit and Git itself deserve to be called porcelains.
@noindent
-This manual is for Magit version v3.3.0-99-g2914b9202+1.
+This manual is for Magit version v3.3.0-100-g5f23bcd77+1.
@quotation
Copyright (C) 2015-2022 Jonas Bernoulli <jonas@@bernoul.li>
@@ -3230,6 +3230,14 @@ minibuffer.
@findex magit-log-head
Show log for @code{HEAD}.
+@item @kbd{l u} (@code{magit-log-related})
+@kindex l u
+@findex magit-log-related
+Show log for the current branch, its upstream and its push target.
+When the upstream is a local branch, then also show its own
+upstream. When @code{HEAD} is detached, then show log for that, the
+previously checked out branch and its upstream and push-target.
+
@item @kbd{l o} (@code{magit-log-other})
@kindex l o
@findex magit-log-other
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index 59f4face72..fbaeff58c4 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -41,6 +41,8 @@
(&optional branch pull keyword))
(declare-function magit-read-file-from-rev "magit-files"
(rev prompt &optional default))
+(declare-function magit-rebase--get-state-lines "magit-sequence"
+ (file))
(declare-function magit-show-commit "magit-diff"
(arg1 &optional arg2 arg3 arg4))
(declare-function magit-reflog-format-subject "magit-reflog" (subject))
@@ -439,6 +441,7 @@ the upstream isn't ahead of the current branch) show."
[["Log"
("l" "current" magit-log-current)
("h" "HEAD" magit-log-head)
+ ("u" "related" magit-log-related)
("o" "other" magit-log-other)]
[""
("L" "local branches" magit-log-branches)
@@ -640,6 +643,35 @@ one or more revs read from the minibuffer."
(interactive (magit-log-arguments))
(magit-log-setup-buffer (list "HEAD") args files))
+;;;###autoload
+(defun magit-log-related (revs &optional args files)
+ "Show log for the current branch, its upstream and its push target.
+When the upstream is a local branch, then also show its own
+upstream. When `HEAD' is detached, then show log for that, the
+previously checked out branch and its upstream and push-target."
+ (interactive
+ (cons (let ((current (magit-get-current-branch))
+ head rebase target upstream upup)
+ (unless current
+ (setq rebase (magit-rebase--get-state-lines "head-name"))
+ (cond (rebase
+ (setq rebase (magit-ref-abbrev rebase))
+ (setq current rebase)
+ (setq head "HEAD"))
+ (t (setq current (magit-get-previous-branch)))))
+ (cond (current
+ (setq current
+ (magit--propertize-face current'magit-branch-local))
+ (setq target (magit-get-push-branch current t))
+ (setq upstream (magit-get-upstream-branch current))
+ (when upstream
+ (setq upup (and (magit-local-branch-p upstream)
+ (magit-get-upstream-branch upstream)))))
+ (t (setq head "HEAD")))
+ (delq nil (list current head target upstream upup)))
+ (magit-log-arguments)))
+ (magit-log-setup-buffer revs args files))
+
;;;###autoload
(defun magit-log-other (revs &optional args files)
"Show log for one or more revs read from the minibuffer.