diff options
| author | Kyle Meyer <kyle@kyleam.com> | 2023-10-23 00:20:14 -0400 |
|---|---|---|
| committer | Kyle Meyer <kyle@kyleam.com> | 2023-10-23 00:20:14 -0400 |
| commit | fbb32ee30fbfbf9dc081187aab9931cfcf55f5d5 (patch) | |
| tree | b06580627057d1433b69598a402475966c79a88e | |
| parent | dd14e0c3c6604f97a447967f0c1ace9947a09e66 (diff) | |
magit-insert-am-sequence: Account for already applied patches
magit-insert-am-sequence inserts a section for all patches in
$GIT_DIR/rebase-apply/ and then displays ORIG_HEAD through HEAD via
magit-sequence-insert-sequence. If the 'git am' call fails to apply a
patch, this leads to repeated sections for successfully applied
patches because Git leaves the patch files around after successfully
applying a patch.
Avoid the repeated sections by explicitly inserting a section only for
$GIT_DIR/rebase-apply/ patches that have not been applied, leaving the
rest to the magit-sequence-insert-sequence call.
Closes #5024.
| -rw-r--r-- | docs/RelNotes/4.0.0.org | 4 | ||||
| -rw-r--r-- | lisp/magit-sequence.el | 27 |
2 files changed, 21 insertions, 10 deletions
diff --git a/docs/RelNotes/4.0.0.org b/docs/RelNotes/4.0.0.org index 3ba3e65..2af6261 100644 --- a/docs/RelNotes/4.0.0.org +++ b/docs/RelNotes/4.0.0.org @@ -223,6 +223,10 @@ f9ae2a6306 #4620 magit-blame--make-highlight-overlay: Add only to intended line mode change and point is on the file or the mode change section. #4623 +- If applying a patch series with ~git am~ failed, the status buffer + incorrectly repeated already applied patches in the list of + remaining patches. #5024 + 10b5407131 magit-diff-highlight-list: Ensure delayed highlighting takes place b32521d543 magit-ediff-read-files: Handle renames in one-file logs 94aca04dc8 magit-module-section: Use correct keymap diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el index 2b210a5..5a8b66b 100644 --- a/lisp/magit-sequence.el +++ b/lisp/magit-sequence.el @@ -914,24 +914,31 @@ If no such sequence is in progress, do nothing." (when (magit-am-in-progress-p) (magit-insert-section (rebase-sequence) (magit-insert-heading "Applying patches") - (let ((patches (nreverse (magit-rebase-patches))) - patch commit) - (while patches + (let* ((patches (nreverse (magit-rebase-patches))) + (dir (expand-file-name "rebase-apply" (magit-gitdir))) + (i (string-to-number + (magit-file-line (expand-file-name "last" dir)))) + (cur (string-to-number + (magit-file-line (expand-file-name "next" dir)))) + patch commit) + (while (and patches (>= i cur)) (setq patch (pop patches)) (setq commit (magit-commit-p (cadr (split-string (magit-file-line patch))))) - (cond ((and commit patches) + (cond ((and commit (= i cur)) (magit-sequence-insert-commit - "pick" commit 'magit-sequence-pick)) - (patches + "stop" commit 'magit-sequence-stop)) + ((= i cur) (magit-sequence-insert-am-patch - "pick" patch 'magit-sequence-pick)) + "stop" patch 'magit-sequence-stop)) (commit - (magit-sequence-insert-sequence commit "ORIG_HEAD")) + (magit-sequence-insert-commit + "pick" commit 'magit-sequence-pick)) (t (magit-sequence-insert-am-patch - "stop" patch 'magit-sequence-stop) - (magit-sequence-insert-sequence nil "ORIG_HEAD"))))) + "pick" patch 'magit-sequence-pick))) + (cl-decf i))) + (magit-sequence-insert-sequence nil "ORIG_HEAD") (insert ?\n)))) (defun magit-sequence-insert-am-patch (type patch face) |
