emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit ff32698 1/2: magit-cherry-branch: Support using


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit ff32698 1/2: magit-cherry-branch: Support using detached HEAD as source
Date: Fri, 3 Dec 2021 16:57:39 -0500 (EST)

branch: elpa/git-commit
commit ff3269814c33a37ad7d4fd6ca927dcc6131b0bbd
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-cherry-branch: Support using detached HEAD as source
    
    Closes #4534.
---
 Documentation/magit.org  |  3 ++-
 Documentation/magit.texi |  7 ++++---
 lisp/magit-sequence.el   | 15 ++++++++++-----
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/Documentation/magit.org b/Documentation/magit.org
index 5a2ffe9..a09427a 100644
--- a/Documentation/magit.org
+++ b/Documentation/magit.org
@@ -6014,7 +6014,8 @@ same way you would have to if these commands didn't exist 
at all.
 
   This command moves the selected COMMITS from the current branch onto
   another existing BRANCH, removing them from the former.  When this
-  command succeeds, then the same branch is current as before.
+  command succeeds, then the same branch is current as before.  ~HEAD~
+  is allowed to be detached initially.
 
   Applying the commits on the other branch or removing them from the
   current branch can lead to conflicts.  When that happens, then this
diff --git a/Documentation/magit.texi b/Documentation/magit.texi
index d362dd6..3107005 100644
--- a/Documentation/magit.texi
+++ b/Documentation/magit.texi
@@ -31,7 +31,7 @@ General Public License for more details.
 @finalout
 @titlepage
 @title Magit User Manual
-@subtitle for version 3.3.0 (v3.3.0-40-g6da7771b6+1)
+@subtitle for version 3.3.0 (v3.3.0-46-g5a8bbe1a8+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 3.3.0 (v3.3.0-40-g6da7771b6+1).
+This manual is for Magit version 3.3.0 (v3.3.0-46-g5a8bbe1a8+1).
 
 @quotation
 Copyright (C) 2015-2021 Jonas Bernoulli <jonas@@bernoul.li>
@@ -8067,7 +8067,8 @@ the process manually.
 
 This command moves the selected COMMITS from the current branch onto
 another existing BRANCH, removing them from the former.  When this
-command succeeds, then the same branch is current as before.
+command succeeds, then the same branch is current as before.  @code{HEAD}
+is allowed to be detached initially.
 
 Applying the commits on the other branch or removing them from the
 current branch can lead to conflicts.  When that happens, then this
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index cf5b775..07809ff 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -172,14 +172,15 @@ This discards all changes made since the sequence 
started."
             (magit-read-other-branch-or-commit prompt))
         (transient-args 'magit-cherry-pick)))
 
-(defun magit--cherry-move-read-args (verb away fn)
+(defun magit--cherry-move-read-args (verb away fn &optional allow-detached)
   (declare (indent defun))
   (let ((commits (or (nreverse (magit-region-values 'commit))
                      (list (funcall (if away
                                         'magit-read-branch-or-commit
                                       'magit-read-other-branch-or-commit)
                                     (format "%s cherry" (capitalize verb))))))
-        (current (magit-get-current-branch)))
+        (current (or (magit-get-current-branch)
+                     (and allow-detached (magit-rev-parse "HEAD")))))
     (unless current
       (user-error "Cannot %s cherries while HEAD is detached" verb))
     (let ((reachable (magit-rev-ancestor-p (car commits) current))
@@ -239,13 +240,17 @@ process manually."
   "Move COMMITS from the current branch onto another existing BRANCH.
 Remove COMMITS from the current branch and stay on that branch.
 If a conflict occurs, then you have to fix that and finish the
-process manually."
+process manually.  `HEAD' is allowed to be detached initially."
   (interactive
    (magit--cherry-move-read-args "donate" t
      (lambda (commits)
        (list (magit-read-other-branch (format "Move %s cherries to branch"
-                                              (length commits)))))))
-  (magit--cherry-move commits (magit-get-current-branch) branch args))
+                                              (length commits)))))
+     'allow-detached))
+  (magit--cherry-move commits
+                      (or (magit-get-current-branch)
+                          (magit-rev-parse "HEAD"))
+                      branch args))
 
 ;;;###autoload
 (defun magit-cherry-spinout (commits branch start-point &optional args)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]