feat: keep original patch headers
This commit is contained in:
parent
833280f1a9
commit
a85bf4c080
1 changed files with 20 additions and 6 deletions
18
apatch
18
apatch
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue