From 20c8ea7097cea73196ca97cb7c939c43b43b047b Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 2 Nov 2021 03:15:41 +0100 Subject: scripts: Review patch_git.sh and update-patches-git Fix git-backed package patching and patch updating scripts: * patch_git.sh was entirely broken (since forever?!) due to a missing 'cd' call * update-patches-git formatted the marker commit as patch instead of ignoring it The major improvement of this review is the elimination of the mandatory final marker commit. Putting it before the series being applied works well and allows to add a patch to the series without demanding a git-rebase call to get the marker back on top. While being at it: * Call 'git am --abort' only if there was a git repo already * Call git-commit and git-format-patch with extra options to avoid side-effects from a user's .gitconfig * Explicitly specify output format in git-log to avoid surprises, also split output properly with 'read' * Eliminate fake_hdr variable Signed-off-by: Phil Sutter --- scripts/update-patches-git | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'scripts/update-patches-git') 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 +# (c) 2021 Phil Sutter 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 -- cgit v1.2.3