Comments (4)
Here's a minimal reproducer for the Magit repo:
#!/bin/sh
set -eu
commit=6e394b8928bab7922478566c4eb2f7cf0a6edd8e
git checkout "$commit"~2
git format-patch --no-cover-letter -n2 --stdout "$commit" |
# Remove commit to make magit-insert-am-sequence go through
# `patches' arm.
sed 's/^From .*/From git@z Thu Jan 1 00:00:00 1970/' |
# Trigger failure in second patch.
sed 's/dropped."/ &1/' |
git am
That leads to the following status buffer:
Applying patches
pick 0002 [PATCH 2/2] magit-log-remove-graph-args: Discourage customization
stop 0001 [PATCH 1/2] magit-section--enable-long-lines-shortcuts: Fix message
done 3f0c923c magit-section--enable-long-lines-shortcuts: Fix message typos
onto fc71a772 magit-blame--parse-chunk: Cosmetics
I'm out of time to look into this more tonight, but quickly glancing at magit-insert-am-sequence
, it looks like it incorrectly assumes that a patch is deleted from $GIT_DIR/rebase-apply/
after being successfully applied.
from magit.
As a first step, I'll try to reduce this down to a smaller reproducer. And I expect b4 can be taken out of the equation.
from magit.
I'm not sure what magit-commit-p is meant to be doing but noodling about in ielm:
ELISP> (--map (magit-file-line it) (nreverse (magit-rebase-patches)))
("From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970" "From git@z Thu Jan 1 00:00:00 1970")
ELISP> (--map (cadr (split-string (magit-file-line it))) (nreverse (magit-rebase-patches)))
("git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z" "git@z")
ELISP> (--map (magit-commit-p
(cadr (split-string (magit-file-line it)))) (nreverse (magit-rebase-patches)))
(nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil)
but if its meant to pick up applied patches and it did we could switch patches/commit checks in cond .
from magit.
I'm not sure what magit-commit-p is meant to be doing
That checks whether an object for a commit named in the From_
line (i.e. what comes straight from git-format-patch
) is present locally. You can trigger that codepath if you drop the first sed
line in my script above. It doesn't come into play for the standard patch workflow where commits for the sender's patches aren't present in the applier's repo.
Here's my initial crack at dropping the already applied patches from the display. With light testing, what's displayed looks reasonable to me, but I've yet to test it more thoroughly (edge cases, older Git versions, ...). I won't get to that until at least this weekend.
diff
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index 2b210a57..c4f204ff 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -914,24 +914,31 @@ (defun magit-insert-am-sequence ()
(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)
Applying patches section
Tweaked script to add one more patch:
#!/bin/sh
set -eu
commit=c5597033d8cde513d124d9054ec0ad5f04889c20
git checkout "$commit"~3
git format-patch --no-cover-letter -n3 --stdout "$commit" |
# Remove commit to make magit-insert-am-sequence go through
# `patches' arm.
sed 's/^From .*/From git@z Thu Jan 1 00:00:00 1970/' |
# Trigger failure in second patch.
sed 's/dropped."/ &1/' |
git am
Applying patches
pick 0003 [PATCH 3/3] magit-section-{pre,post}-command-hook: Don't suppress in
stop 0002 [PATCH 2/3] magit-log-remove-graph-args: Discourage customization
done 019726ec magit-section--enable-long-lines-shortcuts: Fix message typos
onto fc71a772 magit-blame--parse-chunk: Cosmetics
from magit.
Related Issues (20)
- Stage hunk in tramp session result in infinity loop HOT 2
- When doing worktree diff with a commit, apply/reverse doesn't work in the diff buffer HOT 3
- Setting `safe.bareRepository=explicit` breaks magit commit HOT 1
- magit-diff-paths output is not washed HOT 1
- Error in `magit-repolist-column-version` function: (wrong-type-argument integer-or-marker-p nil) HOT 1
- `magit-log` with `--author=` argument hangs with `vertico-mode` when `transient-default-level` is 7 HOT 2
- Magit should always specify --git-dir or GIT_DIR when cd-ing to a gitdir to run some Git subcommand. HOT 19
- Binding C-<tab> conflicts with Emacs' tab-bar-mode HOT 1
- Non-existing tramp function advised in magit-process.el HOT 1
- Confirm commit message when running emacs as client HOT 5
- Trying to visit files in `magit-diff-paths` output leads to wrong path
- large git merges make magit-process buffer grow quickly
- `Filter! diff.ignoreSubmodules=untracked` on top of magit buffer is confusing
- Unable to recursively init submodules HOT 1
- submodule update with universal argument still prompts for submodule selection when there is only one submodule HOT 2
- Invalid slot name: "#<magit-section ...>", :value
- Some update broke my custom git-commit-hook to insert comment into commit buffer HOT 3
- Magit push doesn't respect configured refspecs HOT 2
- Pressing RET (magit-visit-thing) on an URL in the magit-process buffer doesn't open URL HOT 4
- magit-log with --patch but without --graph errors HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magit.