branch: elpa/magit
commit 0376b01d7d2036666dc3e0bc318a235fd88a2686
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-merge-{plain,editmsg,nocommit}: Support creating octopus merges
Closes #5523.
---
docs/magit.org | 6 ++++++
docs/magit.texi | 6 ++++++
lisp/magit-git.el | 17 +++++++++++++++++
lisp/magit-merge.el | 20 +++++++++++++++-----
4 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/docs/magit.org b/docs/magit.org
index 62912c27b5..bbef37890d 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -5783,6 +5783,8 @@ following suffix commands.
merge commit, which makes it possible to inspect how conflicts were
resolved and to adjust the commit message.
+ To create an octopus-merge, separate branches with commas.
+
- Key: m e (magit-merge-editmsg) ::
This command merges another branch or an arbitrary revision into the
@@ -5790,6 +5792,8 @@ following suffix commands.
can make adjustments. The commit is not actually created until the
user finishes with ~C-c C-c~.
+ To create an octopus-merge, separate branches with commas.
+
- Key: m n (magit-merge-nocommit) ::
This command merges another branch or an arbitrary revision into the
@@ -5809,6 +5813,8 @@ following suffix commands.
Finally, if ~magit-branch-pull-request~ was used to create the merged
branch, then the respective remote branch is also removed.
+ To create an octopus-merge, separate branches with commas.
+
- Key: m d (magit-merge-dissolve) ::
This command merges the current branch into another local branch and
diff --git a/docs/magit.texi b/docs/magit.texi
index 3a6b1812e0..48f2c42a9b 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -6825,6 +6825,8 @@ created. With a prefix argument this does not actually
create the
merge commit, which makes it possible to inspect how conflicts were
resolved and to adjust the commit message.
+To create an octopus-merge, separate branches with commas.
+
@item @kbd{m e} (@code{magit-merge-editmsg})
@kindex m e
@findex magit-merge-editmsg
@@ -6833,6 +6835,8 @@ current branch and opens a commit message buffer, so that
the user
can make adjustments. The commit is not actually created until the
user finishes with @code{C-c C-c}.
+To create an octopus-merge, separate branches with commas.
+
@item @kbd{m n} (@code{magit-merge-nocommit})
@kindex m n
@findex magit-merge-nocommit
@@ -6854,6 +6858,8 @@ stuck on some obsolete version of the commits that are
being merged.
Finally, if @code{magit-branch-pull-request} was used to create the merged
branch, then the respective remote branch is also removed.
+To create an octopus-merge, separate branches with commas.
+
@item @kbd{m d} (@code{magit-merge-dissolve})
@kindex m d
@findex magit-merge-dissolve
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 02cdf532a2..2c29cd3da9 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2822,6 +2822,23 @@ If either revision cannot be dereferenced as a commit,
signal an error."
(magit-completing-read prompt (delete exclude (magit-list-refnames))
nil 'any nil 'magit-revision-history default))))
+(defun magit-read-other-branches-or-commits
+ (prompt &optional exclude secondary-default)
+ (let* ((current (magit-get-current-branch))
+ (atpoint (magit-branch-or-commit-at-point))
+ (exclude (or exclude current))
+ (default (or (and (not (equal atpoint exclude))
+ (not (and (not current)
+ (magit-rev-equal atpoint "HEAD")))
+ atpoint)
+ (and (not (equal current exclude)) current)
+ secondary-default
+ (magit-get-previous-branch))))
+ (minibuffer-with-setup-hook #'magit--minibuf-default-add-commit
+ (magit-completing-read-multiple
+ prompt (delete exclude (magit-list-refnames))
+ nil 'any nil 'magit-revision-history default))))
+
(defun magit-read-other-local-branch
(prompt &optional exclude secondary-default)
(let* ((current (magit-get-current-branch))
diff --git a/lisp/magit-merge.el b/lisp/magit-merge.el
index 1f5806beb2..33da15b583 100644
--- a/lisp/magit-merge.el
+++ b/lisp/magit-merge.el
@@ -95,8 +95,10 @@ the user inspect the result. With a prefix argument pretend
the
merge failed to give the user the opportunity to inspect the
merge.
+To create an octopus-merge, separate branches with commas.
+
\(git merge --no-edit|--no-commit [ARGS] REV)"
- (interactive (list (magit-read-other-branch-or-commit "Merge")
+ (interactive (list (magit-read-other-branches-or-commits "Merge")
(magit-merge-arguments)
current-prefix-arg))
(magit-merge-assert)
@@ -105,10 +107,14 @@ merge.
;;;###autoload
(defun magit-merge-editmsg (rev &optional args)
"Merge commit REV into the current branch; and edit message.
+
Perform the merge and prepare a commit message but let the user
edit it.
-\n(git merge --edit --no-ff [ARGS] REV)"
- (interactive (list (magit-read-other-branch-or-commit "Merge")
+
+To create an octopus-merge, separate branches with commas.
+
+\(git merge --edit --no-ff [ARGS] REV)"
+ (interactive (list (magit-read-other-branches-or-commits "Merge")
(magit-merge-arguments)))
(magit-merge-assert)
(cl-pushnew "--no-ff" args :test #'equal)
@@ -117,10 +123,14 @@ edit it.
;;;###autoload
(defun magit-merge-nocommit (rev &optional args)
"Merge commit REV into the current branch; pretending it failed.
+
Pretend the merge failed to give the user the opportunity to
inspect the merge and change the commit message.
-\n(git merge --no-commit --no-ff [ARGS] REV)"
- (interactive (list (magit-read-other-branch-or-commit "Merge")
+
+To create an octopus-merge, separate branches with commas.
+
+\(git merge --no-commit --no-ff [ARGS] REV)"
+ (interactive (list (magit-read-other-branches-or-commits "Merge")
(magit-merge-arguments)))
(magit-merge-assert)
(cl-pushnew "--no-ff" args :test #'equal)