summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRoland Hieber <rhi@pengutronix.de>2019-11-18 10:32:40 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2019-12-05 14:38:32 +0100
commit8b167e6a799c9747d760e1bda5dd586b9b3f0b18 (patch)
tree84a60dfba35d8bcfc01f5f5be96d7e702c7f46b4 /scripts
parentb59e09de4a01f6b55f1fa0408d2166022bd67278 (diff)
downloadptxdist-8b167e6a799c9747d760e1bda5dd586b9b3f0b18.tar.gz
ptxdist-8b167e6a799c9747d760e1bda5dd586b9b3f0b18.tar.xz
git-ptx-patches: call git in a pristine environment
The behaviour of git-format-patch can be customized through user-defined variables from the environment or from the user's .gitconfig, like custom regexes for function context in diff hunk headers, or different cleanup options. These things can lead to fuzz in generated patches which cannot easily be reproduced by different users when re-exporting existing patch stacks. Create a wrapper to call git in a pristine environment in order to minimize any differences between user environments, and use it to format the patch stack. Signed-off-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/git-ptx-patches19
1 files changed, 17 insertions, 2 deletions
diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
index 721aa78ba..fe6802730 100755
--- a/scripts/git-ptx-patches
+++ b/scripts/git-ptx-patches
@@ -1,5 +1,20 @@
#!/bin/bash
+# Create a pristine environment to minimize unnecessary fuzz when different
+# users use git-ptx-patches on the same patch stack. That is, don't load any
+# config files, and pin down environment variables which could influence git's
+# behaviour or patch output.
+pristine_git() {
+ # Notes from the git(1) manpage:
+ # - GIT_DIFF_OPTS takes takes precedence over -U command line parameter
+ HOME=/nonexistent \
+ XDG_CONFIG_HOME=/nonexistent \
+ GIT_CONFIG_NOSYSTEM=true \
+ GIT_DIFF_OPTS="-u3" \
+ git "$@"
+}
+GIT="pristine_git"
+
PTX_PATCHES_HEADER="# generated by git-ptx-patches"
function _md5sum() {
@@ -116,7 +131,7 @@ case "$remove_old" in
esac
# git-format-patch --no-signature is supported since git 1.7.2
-if git format-patch -h 2>&1 | grep -q signature; then
+if ${GIT} format-patch -h 2>&1 | grep -q signature; then
GIT_EXTRA_ARGS="--no-signature"
fi
@@ -129,7 +144,7 @@ fi
GIT_EXTRA_ARGS="$GIT_EXTRA_ARGS --summary --stat=80"
cat .ptxdist/series.0 > .ptxdist/series
-git format-patch -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/ ${range} | sed -e 's,^.ptxdist/patches/,,' > .ptxdist/series.auto
+${GIT} format-patch -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/ ${range} | sed -e 's,^.ptxdist/patches/,,' > .ptxdist/series.auto
cat .ptxdist/series.auto >> .ptxdist/series
cat .ptxdist/series.1 >> .ptxdist/series
cat .ptxdist/series | _md5sum >> .ptxdist/series