💾 Archived View for idiomdrottning.org › patches-with-notmuch captured on 2024-05-10 at 11:24:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-12-28)

-=-=-=-=-=-=-

Applying thread patches with Emacs Notmuch

I have made this shell script called git-inled in my path.

#!/bin/sh

if git show-ref --verify --quiet "refs/heads/$1"; then
    git checkout "$1"
else
    git checkout main
    git checkout -b "$1"
fi

Then I had this snippet copied from somewhere and changed it from always wanting to create new branches to instead use the inled script:

(defun apply-thread-patchset (repo branch)
  (interactive "Dgit repo: \nsbranch name: ")
  (let ((tid notmuch-show-thread-id)
        (tmp "/tmp/notmuch-patchset"))
    (shell-command (format "notmuch-extract-patch %s > %s && ( cd %s && git inled %s && git am %s )"
                           (shell-quote-argument tid)
                           (shell-quote-argument tmp)
                           (shell-quote-argument (expand-file-name repo))
                           (shell-quote-argument branch)
                           (shell-quote-argument tmp)))))

Thanks to the script I added, if the branch already exists, it switches to it, and if it does not exist, it makes sure the new one is branched off of main.

Before, it’d always create new branches and it’d always create them off of where I already was (which got confusing if I was on a dev branch).

Most of the time I actually do want to accept the patches directly on main. That’s one of the advantages of this workflow after all. And that’s what this script also allows me to do, I just enter main as the branchname to apply to. Then I can use git tools on top of that if I want to fix it up further beyond what was addressed in the review process.

Branching & Patching

NIH with a ribbon bookmark

Learn to use email with git! Step four: Dealing with feedback