[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 2b3ffd6426 2/3: magit-worktree-{checkout, branc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 2b3ffd6426 2/3: magit-worktree-{checkout, branch}: Improve error reporting |
Date: |
Sun, 28 Jul 2024 16:00:16 -0400 (EDT) |
branch: elpa/git-commit
commit 2b3ffd64260b2d218525b604649af588ae6e7d4d
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit-worktree-{checkout,branch}: Improve error reporting
If `git worktree' fails, likely due to user-error, then do not try to
visit the worktree that would have been created on success. That way
the user gets to see the error, which explains what they did wrong,
instead of an additional error, which hides the cause.
---
lisp/magit-worktree.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lisp/magit-worktree.el b/lisp/magit-worktree.el
index cb532c48ec..b063ea84f3 100644
--- a/lisp/magit-worktree.el
+++ b/lisp/magit-worktree.el
@@ -61,8 +61,9 @@ Used by `magit-worktree-checkout' and
`magit-worktree-branch'."
(list (funcall magit-worktree-read-directory-name-function
(format "Checkout %s in new worktree: " branch))
branch)))
- (magit-run-git "worktree" "add" (magit--expand-worktree path) branch)
- (magit-diff-visit-directory path))
+ (when (zerop (magit-run-git "worktree" "add"
+ (magit--expand-worktree path) branch))
+ (magit-diff-visit-directory path)))
;;;###autoload
(defun magit-worktree-branch (path branch start-point &optional force)
@@ -72,9 +73,9 @@ Used by `magit-worktree-checkout' and
`magit-worktree-branch'."
"Create worktree: ")
,@(magit-branch-read-args "Create and checkout branch")
,current-prefix-arg))
- (magit-run-git "worktree" "add" (if force "-B" "-b")
- branch (magit--expand-worktree path) start-point)
- (magit-diff-visit-directory path))
+ (when (zerop (magit-run-git "worktree" "add" (if force "-B" "-b")
+ branch (magit--expand-worktree path)
start-point))
+ (magit-diff-visit-directory path)))
;;;###autoload
(defun magit-worktree-move (worktree path)