feat: keep original patch headers
This commit is contained in:
parent
833280f1a9
commit
a85bf4c080
1 changed files with 20 additions and 6 deletions
26
apatch
26
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
|
||||||
|
@ -85,10 +93,16 @@ done
|
||||||
|
|
||||||
$SHELL
|
$SHELL
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
git diff --cached > "$patchpath"
|
|
||||||
if [ ! -s "$patchpath" ]; then
|
msg "saving patch $patch"
|
||||||
echo "[*] patch is empty, removing"
|
echo -n "$header" > "$patchpath"
|
||||||
rm "$patchpath"
|
git diff --cached >> "$patchpath"
|
||||||
fi
|
|
||||||
|
if [ ! -s "$patchpath" ]; then
|
||||||
|
msg "patch is empty, removing"
|
||||||
|
rm "$patchpath"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf .git
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue