summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/patch_git.sh32
-rw-r--r--scripts/update-patches-git27
2 files changed, 26 insertions, 33 deletions
diff --git a/scripts/patch_git.sh b/scripts/patch_git.sh
index 36a2d6af8..40653a576 100644
--- a/scripts/patch_git.sh
+++ b/scripts/patch_git.sh
@@ -3,7 +3,7 @@
# Patch sources using git-am, aligning things to use git-format-patch for
# update-patches.
#
-# (c) 2016 Phil Sutter <phil@nwl.cc>
+# (c) 2021 Phil Sutter <phil@nwl.cc>
#
# Based on the classic patch.sh, written by:
#
@@ -36,14 +36,11 @@ if [ ! -d .git ]; then
find . -name .gitignore -delete
git init
git add .
- git commit -a --allow-empty \
- --author="OpenADK <wbx@openadk.org>" \
- -m "OpenADK patch marker: 0000"
+elif [ -e .git/rebase-apply ]; then
+ git am --abort
fi
-[ -e .git/rebase-apply ] && \
- git am --abort
-i=1
+i=0
patch_tmp=$(printf ".git/patch_tmp/%04d" $i)
while [ -d $patch_tmp ]; do
let "i++"
@@ -52,6 +49,10 @@ done
mkdir -p $patch_tmp
patch_series=$(printf "%04d" $i)
+git commit --allow-empty --no-signoff --no-gpg-sign \
+ --author="OpenADK <wbx@openadk.org>" \
+ -m "OpenADK patch marker: $patch_series"
+
cd $wd
cd $patchdir
for i in $(eval echo ${patchpattern}); do
@@ -74,12 +75,15 @@ for i in $(eval echo ${patchpattern}); do
esac
[ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue
echo "$(basename $i)" >>${targetdir}/${patch_tmp}/__patchfiles__
- fake_hdr=""
patchname="$(basename -s .gz -s .bz -s .bz2 -s .zip -s .Z -s .patch $i)"
- if ! grep -q '^Subject: ' ${i}; then
- fake_hdr="From: OpenADK <wbx@openadk.org>\nSubject: [PATCH] ${patchname#[0-9]*-}\n\n"
- fi
- { echo -en $fake_hdr; ${uncomp} ${i}; } >${targetdir}/${patch_tmp}/${patchname}.patch
+ {
+ if ! grep -q '^Subject: ' ${i}; then
+ echo "From: OpenADK <wbx@openadk.org>"
+ echo "Subject: [PATCH] ${patchname#[0-9]*-}"
+ echo ""
+ fi
+ ${uncomp} ${i}
+ } >${targetdir}/${patch_tmp}/${patchname}.patch
cd $patchdir
done
@@ -93,6 +97,7 @@ done
# XXX: this is unsafe and should be dropped at some point
am_opts="-C1"
+cd ${wd}
realpath $patchdir >${targetdir}/${patch_tmp}/__patchdir__
cd ${targetdir}
git am $am_opts ${patch_tmp}/*.patch
@@ -100,6 +105,3 @@ if [ $? != 0 ] ; then
echo "git-am failed! Please fix patches!"
exit 1
fi
-git commit -a --allow-empty \
- --author="OpenADK <wbx@openadk.org>" \
- -m "OpenADK patch marker: $patch_series"
diff --git a/scripts/update-patches-git b/scripts/update-patches-git
index 8337fa847..6f0bbfedb 100644
--- a/scripts/update-patches-git
+++ b/scripts/update-patches-git
@@ -3,29 +3,20 @@
# Update patches using git-format-patch from a source tree prepared by
# patch_git.sh.
#
-# (c) 2016 Phil Sutter <phil@nwl.cc>
+# (c) 2021 Phil Sutter <phil@nwl.cc>
wrkdist=$1
wd=$(pwd)
cd "$wrkdist"
-top=""
-top_series=""
-git log --grep="^OpenADK patch marker:" --oneline | while read hash subject; do
- [ -n "$top" ] || {
- top=$hash
- top_series="${subject#OpenADK patch marker: }"
- continue
- }
- bottom=$hash
- bottom_series="${subject#OpenADK patch marker: }"
-
- patchdir=$(<.git/patch_tmp/${top_series}/__patchdir__)
+top="HEAD"
+git log --grep='^OpenADK patch marker:' --format='%H %s'$logopt | \
+ while read hash o p m series; do
+ patchdir=$(<.git/patch_tmp/${series}/__patchdir__)
while read patchfile; do
rm ${patchdir}/$patchfile
- done < .git/patch_tmp/${top_series}/__patchfiles__
- git format-patch -N -o "$patchdir" ${bottom}..${top}
-
- top=$bottom
- top_series=$bottom_series
+ done < .git/patch_tmp/${series}/__patchfiles__
+ git format-patch --no-numbered --no-signoff --no-cover-letter \
+ --no-signature -o "$patchdir" ${hash}..${top}
+ top=${hash}^
done