[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 2ddb7ca45e: Mark async branch and checkout comm
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/git-commit 2ddb7ca45e: Mark async branch and checkout commands for interactive use only |
|
Date: |
Sun, 21 May 2023 17:01:24 -0400 (EDT) |
branch: elpa/git-commit
commit 2ddb7ca45e52ac43762ac769b4a50b92c67f9d21
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Mark async branch and checkout commands for interactive use only
Also fix `magit-stash-branch-here', which broke when we made these
commands asynchronous in [1: 25dbf32d86].
Closes #4945.
1: 2023-04-24 25dbf32d86eaf1ccb7b652b2de392d749c4c2186
Perform checkouts asynchronously
---
docs/magit.org | 11 ++++++-----
docs/magit.texi | 11 ++++++-----
lisp/magit-branch.el | 25 ++++++++++++++++++++-----
lisp/magit-extras.el | 2 +-
lisp/magit-stash.el | 15 +++++++++------
5 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/docs/magit.org b/docs/magit.org
index 0b172e5e06..d58d3a8fae 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -6372,14 +6372,15 @@ Also see [[man:git-stash]]
- Key: z b (magit-stash-branch) ::
- Create and checkout a new BRANCH from STASH. The branch starts at
- the commit that was current when the stash was created.
+ Create and checkout a new branch from an existing stash. The new
+ branch starts at the commit that was current when the stash was
+ created.
- Key: z B (magit-stash-branch-here) ::
- Create and checkout a new BRANCH using ~magit-branch~ with the current
- branch or ~HEAD~ as the starting-point. Then apply STASH, dropping it
- if it applies cleanly.
+ Create and checkout a new branch from an existing stash. Use the
+ current branch or ~HEAD~ as the starting-point of the new branch.
+ Then apply the stash, dropping it if it applies cleanly.
- Key: z f (magit-stash-format-patch) ::
diff --git a/docs/magit.texi b/docs/magit.texi
index a242f7ea01..f54b1a7af1 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -7851,15 +7851,16 @@ Show all diffs of a stash in a buffer.
@item @kbd{z b} (@code{magit-stash-branch})
@kindex z b
@findex magit-stash-branch
-Create and checkout a new BRANCH from STASH@. The branch starts at
-the commit that was current when the stash was created.
+Create and checkout a new branch from an existing stash. The new
+branch starts at the commit that was current when the stash was
+created.
@item @kbd{z B} (@code{magit-stash-branch-here})
@kindex z B
@findex magit-stash-branch-here
-Create and checkout a new BRANCH using @code{magit-branch} with the current
-branch or @code{HEAD} as the starting-point. Then apply STASH, dropping it
-if it applies cleanly.
+Create and checkout a new branch from an existing stash. Use the
+current branch or @code{HEAD} as the starting-point of the new branch.
+Then apply the stash, dropping it if it applies cleanly.
@item @kbd{z f} (@code{magit-stash-format-patch})
@kindex z f
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index 98b66e3647..27b819117d 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -254,15 +254,22 @@ branch. If it is something else, then `HEAD' becomes
detached.
Checkout fails if the working tree or the staging area contain
changes.
\n(git checkout REVISION)."
+ (declare (interactive-only magit--checkout))
(interactive (list (magit-read-other-branch-or-commit "Checkout")
(magit-branch-arguments)))
(when (string-match "\\`heads/\\(.+\\)" revision)
(setq revision (match-string 1 revision)))
(magit-run-git-async "checkout" args revision))
+(defun magit--checkout (revision &optional args)
+ (when (string-match "\\`heads/\\(.+\\)" revision)
+ (setq revision (match-string 1 revision)))
+ (magit-call-git "checkout" args revision))
+
;;;###autoload
(defun magit-branch-create (branch start-point)
"Create BRANCH at branch or revision START-POINT."
+ (declare (interactive-only magit-call-git))
(interactive (magit-branch-read-args "Create branch"))
(magit-run-git-async "branch" branch start-point)
(set-process-sentinel
@@ -275,6 +282,7 @@ changes.
;;;###autoload
(defun magit-branch-and-checkout (branch start-point &optional args)
"Create and checkout BRANCH at branch or revision START-POINT."
+ (declare (interactive-only magit-call-git))
(interactive (append (magit-branch-read-args "Create and checkout branch")
(list (magit-branch-arguments))))
(if (string-match-p "^stash@{[0-9]+}$" start-point)
@@ -299,6 +307,7 @@ Otherwise create and checkout a new branch using the input
as
its name. Before doing so read the starting-point for the new
branch. This is similar to what `magit-branch-and-checkout'
does."
+ (declare (interactive-only magit-call-git))
(interactive
(let ((arg (magit-read-other-branch-or-commit "Checkout")))
(list arg
@@ -307,8 +316,10 @@ does."
(when (string-match "\\`heads/\\(.+\\)" arg)
(setq arg (match-string 1 arg)))
(if start-point
- (magit-branch-and-checkout arg start-point)
- (magit-checkout arg)))
+ (with-suppressed-warnings ((interactive-only magit-branch-and-checkout))
+ (magit-branch-and-checkout arg start-point))
+ (magit--checkout arg)
+ (magit-refresh)))
;;;###autoload
(defun magit-branch-checkout (branch &optional start-point)
@@ -334,6 +345,7 @@ In the latter two cases the upstream is also set. Whether
it is
set to the chosen START-POINT or something else depends on the
value of `magit-branch-adjust-remote-upstream-alist', just like
when using `magit-branch-and-checkout'."
+ (declare (interactive-only magit-call-git))
(interactive
(let* ((current (magit-get-current-branch))
(local (magit-list-local-branch-names))
@@ -359,8 +371,11 @@ when using `magit-branch-and-checkout'."
(list choice))
(t
(list choice (magit-read-starting-point "Create" choice))))))
- (if (not start-point)
- (magit-checkout branch (magit-branch-arguments))
+ (cond
+ ((not start-point)
+ (magit--checkout branch (magit-branch-arguments))
+ (magit-refresh))
+ (t
(when (magit-anything-modified-p t)
(user-error "Cannot checkout when there are uncommitted changes"))
(magit-run-git-async "checkout" (magit-branch-arguments)
@@ -376,7 +391,7 @@ when using `magit-branch-and-checkout'."
(when (and (equal branch remote-branch)
(not (equal remote (magit-get "remote.pushDefault"))))
(magit-set remote "branch" branch "pushRemote"))))
- (magit-process-sentinel process event))))))
+ (magit-process-sentinel process event)))))))
(defun magit-branch-maybe-adjust-upstream (branch start-point)
(--when-let
diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el
index a879520954..2f938c81aa 100644
--- a/lisp/magit-extras.el
+++ b/lisp/magit-extras.el
@@ -468,7 +468,7 @@ points at it) otherwise."
(if rebase
(let ((magit--rebase-published-symbol 'edit-published))
(magit-rebase-edit-commit rev (magit-rebase-arguments)))
- (magit-checkout (or (magit-rev-branch rev) rev)))
+ (magit--checkout (or (magit-rev-branch rev) rev)))
(unless (and buffer-file-name
(file-equal-p file buffer-file-name))
(let ((blame-type (and magit-blame-mode magit-blame-type)))
diff --git a/lisp/magit-stash.el b/lisp/magit-stash.el
index f471e27f41..c3efef167a 100644
--- a/lisp/magit-stash.el
+++ b/lisp/magit-stash.el
@@ -282,20 +282,23 @@ When the region is active offer to drop all contained
stashes."
;;;###autoload
(defun magit-stash-branch (stash branch)
- "Create and checkout a new BRANCH from STASH."
+ "Create and checkout a new BRANCH from an existing STASH.
+The new branch starts at the commit that was current when the
+stash was created. If the stash applies cleanly, then drop it."
(interactive (list (magit-read-stash "Branch stash")
(magit-read-string-ns "Branch name")))
(magit-run-git "stash" "branch" branch stash))
;;;###autoload
(defun magit-stash-branch-here (stash branch)
- "Create and checkout a new BRANCH and apply STASH.
-The branch is created using `magit-branch-and-checkout', using the
-current branch or `HEAD' as the start-point."
+ "Create and checkout a new BRANCH from an existing STASH.
+Use the current branch or `HEAD' as the starting-point of BRANCH.
+Then apply STASH, dropping it if it applies cleanly."
(interactive (list (magit-read-stash "Branch stash")
(magit-read-string-ns "Branch name")))
- (let ((magit-inhibit-refresh t))
- (magit-branch-and-checkout branch (or (magit-get-current-branch) "HEAD")))
+ (let ((start-point (or (magit-get-current-branch) "HEAD")))
+ (magit-call-git "checkout" "-b" branch start-point)
+ (magit-branch-maybe-adjust-upstream branch start-point))
(magit-stash-apply stash))
;;;###autoload
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/git-commit 2ddb7ca45e: Mark async branch and checkout commands for interactive use only,
ELPA Syncer <=