fix: don't use $patch as the original patch

This commit is contained in:
ptrcnull 2022-07-30 06:10:25 +02:00
parent f80c534323
commit 4c668b6c04

6
apatch
View file

@ -63,7 +63,7 @@ for patch in $source; do
done
header=""
if [ -f "$patch" ]; then
if [ -f "$patchpath" ]; 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)
@ -81,7 +81,7 @@ fi
git apply --reject --whitespace=fix "$patchpath" || {
rejects="$(git status --porcelain | grep '\?\? .*\.rej$' | cut -c4-)"
if [ -n "$rejects" ]; then
warning "$patch partially applied with rejects"
warning "$1 partially applied with rejects"
for reject in $rejects; do
target="${reject%.rej}"
msg "trying to wiggle $target"
@ -102,7 +102,7 @@ fi
git add .
msg "saving patch $patch"
msg "saving patch $1"
echo -n "$header" > "$patchpath"
git diff --cached >> "$patchpath"