aboutsummaryrefslogblamecommitdiffstats
path: root/git-format-named-patches.sh
blob: a5e4f8bb8bff77ea80d020ebfcc620441b97f5c1 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                   
                                                                                        


                                                     
#!/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" | git interpret-trailers --parse | awk '/^Patch: / {print $2}')"
    [ -z "$FN" ] && fail "Patch filename not defined"
    printf "%s" "$PATCH" > "$FN"
done