Recently Written · git

dpatchmail

Patch programs with a dmenu interface

git clone https://github.com/equwal/dpatchmail

Log | Files | Refs


commit 8be09ae7f67cc4fec6843f826916fba891d45cbc
Spenser Truex <truex@equwal.com>
2025-09-01 18:37:52 -0400

Added patching scripts

 format-patch          | 20 ++++++++++++++++++++
 format-patch-clang    | 25 +++++++++++++++++++++++++
 format-patch-suckless |  2 ++
 3 files changed, 47 insertions(+)
diff --git a/format-patch b/format-patch
new file mode 100755
index 0000000..9784fca
--- /dev/null
+++ b/format-patch
@@ -0,0 +1,20 @@
+#!/bin/sh
+# also see suckless-format-patch and friends
+[ -z "$1" ] && EMAIL="$(prompt-mail)"
+[ -n "$1" ] && EMAIL="$1"
+echo "Formatting a patch file..."
+TAG="$(git tag --points-at HEAD^)"
+TAGDIFF="${PWD##*/}-$(sed 's:.*/::' .git/HEAD)-$(date +%Y%m%d)-$TAG.diff"
+fp () {
+    file="${PWD##*/}-$(sed 's:.*/::' .git/HEAD)-$1.diff"
+    git format-patch \
+        --to "$EMAIL" \
+        --stdout HEAD^ \
+        > "$file" \
+    && echo "Wrote $file."
+}
+[ -n "$TAG" ] && fp "$TAG"
+[ -z "$TAG" ] && fp "$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
+echo "Patch made."
+y-or-n "git-send-email it right now?" && git-send-email --to "$EMAIL" "$file" \
+  && y-or-n "delete patch file?" && rm "$file"
diff --git a/format-patch-clang b/format-patch-clang
new file mode 100755
index 0000000..670c860
--- /dev/null
+++ b/format-patch-clang
@@ -0,0 +1,25 @@
+#!/bin/sh
+# takes extra commands to format-patch as arguments
+[ -z "$1" ] && EMAIL="$(prompt-mail)"
+[ -n "$1" ] && EMAIL="$1"
+echo 'clang-format inplace...'
+y-or-n "Clang format (for C)?" && clang-format -i *.h *.c && echo 'formatted'
+y-or-n "Stage that?" && git stage *.h *.c
+y-or-n "Amend it to commit silently?" && git cane
+echo "Formatting a patch file..."
+TAG="$(git tag --points-at HEAD^)"
+TAGDIFF="${PWD##*/}-$(sed 's:.*/::' .git/HEAD)-$(date +%Y%m%d)-$TAG.diff"
+fp () {
+    file="${PWD##*/}-$(sed 's:.*/::' .git/HEAD)-$1.diff"
+    git format-patch \
+        "$@"
+        --to "$EMAIL" \
+        --stdout HEAD^ \
+    > "$file" \
+    && echo "Wrote $file."
+}
+[ -n "$TAG" ] && fp "$TAG"
+[ -z "$TAG" ] && fp "$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
+echo "Patch made."
+y-or-n "git-send-email it right now?" && git-send-email --to "$EMAIL" "$file" \
+&& y-or-n "delete patch file?" && rm "$file"
diff --git a/format-patch-suckless b/format-patch-suckless
new file mode 100755
index 0000000..cf07791
--- /dev/null
+++ b/format-patch-suckless
@@ -0,0 +1,2 @@
+#!/bin/sh
+format-patch-clang -- --subject-prefix="${PWD##*/}][PATCH"