From b199083197af6d404f9cab31658ae243caedea65 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 4 Apr 2024 09:42:21 +0200 Subject: feat(git-format-named-patches): POC for the script. Just runs individual commits through `git format-patch(1)` and saves them in the named patch files. --- README.md | 2 ++ git-format-named-patches.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 git-format-named-patches.sh diff --git a/README.md b/README.md index 5499271..2896a95 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ git-oci goscb : (probably not needed, when the checkout is primed with `git-obranch`) run `osc build` without regards if `.osc/` directory exists. +git-format-named-patches.sh +: similar to `git format-patch` except the patch files are named according to `Patch: ` trailer in the commit message. All issues, questions, complaints, or (even better!) patches should be send via email to diff --git a/git-format-named-patches.sh b/git-format-named-patches.sh new file mode 100755 index 0000000..e311f5f --- /dev/null +++ b/git-format-named-patches.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -eu + +fail() { + printf "%s\n" "$1" >>/dev/stderr + exit 32 +} + +[ "$#" -lt 1 ] && exit 64 + +IDSstr="$(git log --format="%H" "$1" 2>/dev/null)" +mapfile -t IDS <<< "$IDSstr" +for id in "${IDS[@]}" ; do + PATCH="$(git format-patch -1 --stdout "${id}")" + FN="$(echo "$PATCH" | awk '/^Patch: / {print $2}')" + [ -z "$FN" ] && fail "Patch filename not defined" + printf "%s" "$PATCH" > "$FN" +done -- cgit