diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2026-03-30 21:07:52 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2026-03-30 21:07:52 +0200 |
| commit | 315d85c765afbce10b08c5c9164da64bc789197a (patch) | |
| tree | f18f9cbf067f4d73d217a4925470ee0dd56e8bf4 /lisp | |
| parent | bbaa742cafda74367ec10aa773a8daf0e0c5c7f0 (diff) | |
magit-wip-commit-worktree: Abort if index is locked
Previously an error was signaled when the index was locked by another
process, preventing whatever action would have happened after the
creation of the wip commit. Now we skip creating this wip commit and
show a warning. This effectively suspends the creation of worktree
wip commits.
This issue can be reproduced by initiating but not finishing a commit,
editing but not saving a tracked file, and then refreshing a Magit
buffer.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/magit-wip.el | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el index 8783159..049243b 100644 --- a/lisp/magit-wip.el +++ b/lisp/magit-wip.el @@ -193,18 +193,23 @@ commit message." (setq files (seq-remove #'file-directory-p files))) (let* ((wipref (magit--wip-wtree-ref ref)) (parent (magit-wip-get-parent ref wipref)) - (tree (magit-with-temp-index parent (list "--reset" "-i") - (if files - ;; Use "git update-index" instead of "git add" - ;; because the latter fails if a file is already - ;; deleted in the temporary index. - (magit-wip--git "update-index" "--add" "--remove" - "--ignore-skip-worktree-entries" - "--" files) - (magit-with-toplevel - (magit-wip--git "add" "-u" "."))) - (magit-git-string "write-tree")))) - (magit-wip-update-wipref ref wipref tree parent files msg "worktree")))) + (tree (condition-case nil + (magit-with-temp-index parent (list "--reset" "-i") + (if files + ;; Use "git update-index" instead of "git add" + ;; because the latter fails if a file is already + ;; deleted in the temporary index. + (magit-wip--git "update-index" "--add" "--remove" + "--ignore-skip-worktree-entries" + "--" files) + (magit-with-toplevel + (magit-wip--git "add" "-u" "."))) + (magit-git-string "write-tree")) + (error + (message "Index locked; no worktree wip commit created"))))) + (when tree + (magit-wip-update-wipref ref wipref tree parent + files msg "worktree"))))) (defun magit-wip--git (&rest args) (if magit-wip-debug |
