feat: keep original patch headers

This commit is contained in:
ptrcnull 2022-07-30 02:39:32 +02:00
parent 833280f1a9
commit a85bf4c080

18
apatch
View file

@ -62,6 +62,14 @@ for patch in $source; do
fi fi
done done
header=""
if [ -f "$patch" ]; then
msg "patch exists, trying to extract existing message"
# try to extract the original header from the patch
patch_start=$(grep -En '^(diff --git|--- )' "$patchpath" | cut -d: -f1 | head -n 1)
header="$(head -n $(( patch_start - 1 )) "$patchpath"; echo)"
fi
( (
cd "$builddir" cd "$builddir"
git init git init
@ -86,9 +94,15 @@ done
$SHELL $SHELL
git add . git add .
git diff --cached > "$patchpath"
msg "saving patch $patch"
echo -n "$header" > "$patchpath"
git diff --cached >> "$patchpath"
if [ ! -s "$patchpath" ]; then if [ ! -s "$patchpath" ]; then
echo "[*] patch is empty, removing" msg "patch is empty, removing"
rm "$patchpath" rm "$patchpath"
fi fi
rm -rf .git
) )