mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment
@ 2019-11-11 11:31 Roland Hieber
  2019-11-17 10:31 ` Michael Olbrich
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Roland Hieber @ 2019-11-11 11:31 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

The brhaviour 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>
---
 scripts/git-ptx-patches | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
index 721aa78ba31c..63a1b3921646 100755
--- a/scripts/git-ptx-patches
+++ b/scripts/git-ptx-patches
@@ -1,5 +1,32 @@
 #!/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.
+# Maybe we need to save name and e-mail from the user config…
+# Note from git-commit-tree(1): if set in the user's environment, GIT_AUTHOR_*
+# and GIT_COMMITTER_* still take precedence over the user.* config variables.
+PRISTINE_GIT_AUTHOR=$(git config --get user.name)
+PRISTINE_GIT_EMAIL=$(git config --get user.email)
+PRISTINE_GIT_PARAMS=()
+if [ -n "${PRISTINE_GIT_AUTHOR}" ]; then
+	PRISTINE_GIT_PARAMS+=( -c user.name="${PRISTINE_GIT_AUTHOR}" )
+fi
+if [ -n "${PRISTINE_GIT_EMAIL}" ]; then
+	PRISTINE_GIT_PARAMS+=( -c user.email="${PRISTINE_GIT_EMAIL}" )
+fi
+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 "${PRISTINE_GIT_PARAMS[@]}" "$@"
+}
+GIT="pristine_git"
+
 PTX_PATCHES_HEADER="# generated by git-ptx-patches"
 
 function _md5sum() {
@@ -116,7 +143,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 +156,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
-- 
2.24.0.rc1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment
  2019-11-11 11:31 [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment Roland Hieber
@ 2019-11-17 10:31 ` Michael Olbrich
  2019-11-17 21:57   ` Roland Hieber
  2019-11-18  7:18   ` Alexander Dahl
  2019-11-18  9:21 ` [ptxdist] [PATCH v2] " Roland Hieber
  2019-11-18  9:32 ` [ptxdist] [PATCH v3] " Roland Hieber
  2 siblings, 2 replies; 10+ messages in thread
From: Michael Olbrich @ 2019-11-17 10:31 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

On Mon, Nov 11, 2019 at 12:31:29PM +0100, Roland Hieber wrote:
> The brhaviour 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>
> ---
>  scripts/git-ptx-patches | 31 +++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
> index 721aa78ba31c..63a1b3921646 100755
> --- a/scripts/git-ptx-patches
> +++ b/scripts/git-ptx-patches
> @@ -1,5 +1,32 @@
>  #!/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.
> +# Maybe we need to save name and e-mail from the user config…
> +# Note from git-commit-tree(1): if set in the user's environment, GIT_AUTHOR_*
> +# and GIT_COMMITTER_* still take precedence over the user.* config variables.
> +PRISTINE_GIT_AUTHOR=$(git config --get user.name)
> +PRISTINE_GIT_EMAIL=$(git config --get user.email)
> +PRISTINE_GIT_PARAMS=()
> +if [ -n "${PRISTINE_GIT_AUTHOR}" ]; then
> +	PRISTINE_GIT_PARAMS+=( -c user.name="${PRISTINE_GIT_AUTHOR}" )
> +fi
> +if [ -n "${PRISTINE_GIT_EMAIL}" ]; then
> +	PRISTINE_GIT_PARAMS+=( -c user.email="${PRISTINE_GIT_EMAIL}" )
> +fi

I don't think we need to save user / email here.
git is only used for create patches, not create new commits.

Michael

> +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 "${PRISTINE_GIT_PARAMS[@]}" "$@"
> +}
> +GIT="pristine_git"
> +
>  PTX_PATCHES_HEADER="# generated by git-ptx-patches"
>  
>  function _md5sum() {
> @@ -116,7 +143,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 +156,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
> -- 
> 2.24.0.rc1
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment
  2019-11-17 10:31 ` Michael Olbrich
@ 2019-11-17 21:57   ` Roland Hieber
  2019-11-18  7:18   ` Alexander Dahl
  1 sibling, 0 replies; 10+ messages in thread
From: Roland Hieber @ 2019-11-17 21:57 UTC (permalink / raw)
  To: ptxdist

On Sun, Nov 17, 2019 at 11:31:06AM +0100, Michael Olbrich wrote:
> On Mon, Nov 11, 2019 at 12:31:29PM +0100, Roland Hieber wrote:
> > The brhaviour of git-format-patch can be customized through user-defined

s/brhaviour/behaviour ...

> > 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>
> > ---
> >  scripts/git-ptx-patches | 31 +++++++++++++++++++++++++++++--
> >  1 file changed, 29 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
> > index 721aa78ba31c..63a1b3921646 100755
> > --- a/scripts/git-ptx-patches
> > +++ b/scripts/git-ptx-patches
> > @@ -1,5 +1,32 @@
> >  #!/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.
> > +# Maybe we need to save name and e-mail from the user config…
> > +# Note from git-commit-tree(1): if set in the user's environment, GIT_AUTHOR_*
> > +# and GIT_COMMITTER_* still take precedence over the user.* config variables.
> > +PRISTINE_GIT_AUTHOR=$(git config --get user.name)
> > +PRISTINE_GIT_EMAIL=$(git config --get user.email)
> > +PRISTINE_GIT_PARAMS=()
> > +if [ -n "${PRISTINE_GIT_AUTHOR}" ]; then
> > +	PRISTINE_GIT_PARAMS+=( -c user.name="${PRISTINE_GIT_AUTHOR}" )
> > +fi
> > +if [ -n "${PRISTINE_GIT_EMAIL}" ]; then
> > +	PRISTINE_GIT_PARAMS+=( -c user.email="${PRISTINE_GIT_EMAIL}" )
> > +fi
> 
> I don't think we need to save user / email here.
> git is only used for create patches, not create new commits.

The author name and email go into the patch as well, and those settings
also influence the Signed-off-by tags, if used. I bet there is at least
one user that have configured a different user name or email in their
~/.gitconfig. We should follow the principle of least surprise here and
do the same as git does.

 - Roland

> 
> Michael
> 
> > +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 "${PRISTINE_GIT_PARAMS[@]}" "$@"
> > +}
> > +GIT="pristine_git"
> > +
> >  PTX_PATCHES_HEADER="# generated by git-ptx-patches"
> >  
> >  function _md5sum() {
> > @@ -116,7 +143,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 +156,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
> > -- 
> > 2.24.0.rc1
> > 
> > 
> > _______________________________________________
> > ptxdist mailing list
> > ptxdist@pengutronix.de
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment
  2019-11-17 10:31 ` Michael Olbrich
  2019-11-17 21:57   ` Roland Hieber
@ 2019-11-18  7:18   ` Alexander Dahl
  2019-11-18  9:13     ` Michael Olbrich
  1 sibling, 1 reply; 10+ messages in thread
From: Alexander Dahl @ 2019-11-18  7:18 UTC (permalink / raw)
  To: ptxdist; +Cc: Michael Olbrich, Roland Hieber

Moin,

Am Sonntag, 17. November 2019, 11:31:06 CET schrieb Michael Olbrich:
> On Mon, Nov 11, 2019 at 12:31:29PM +0100, Roland Hieber wrote:
> > The brhaviour 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>
> > ---
> > 
> >  scripts/git-ptx-patches | 31 +++++++++++++++++++++++++++++--
> >  1 file changed, 29 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
> > index 721aa78ba31c..63a1b3921646 100755
> > --- a/scripts/git-ptx-patches
> > +++ b/scripts/git-ptx-patches
> > @@ -1,5 +1,32 @@
> > 
> >  #!/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.
> > +# Maybe we need to save name and e-mail from the user config…
> > +# Note from git-commit-tree(1): if set in the user's environment,
> > GIT_AUTHOR_* +# and GIT_COMMITTER_* still take precedence over the user.*
> > config variables. +PRISTINE_GIT_AUTHOR=$(git config --get user.name)
> > +PRISTINE_GIT_EMAIL=$(git config --get user.email)
> > +PRISTINE_GIT_PARAMS=()
> > +if [ -n "${PRISTINE_GIT_AUTHOR}" ]; then
> > +	PRISTINE_GIT_PARAMS+=( -c user.name="${PRISTINE_GIT_AUTHOR}" )
> > +fi
> > +if [ -n "${PRISTINE_GIT_EMAIL}" ]; then
> > +	PRISTINE_GIT_PARAMS+=( -c user.email="${PRISTINE_GIT_EMAIL}" )
> > +fi
> 
> I don't think we need to save user / email here.
> git is only used for create patches, not create new commits.

I already did this, and not only once:

p --git extract foo
cd platform-bar/build-target/foo-1.2.3
[hack, hack, hack]
git commit -a -m 'baz'
git ptx-patches
…

Greets
Alex

> 
> Michael
> 
> > +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 "${PRISTINE_GIT_PARAMS[@]}" "$@"
> > +}
> > +GIT="pristine_git"
> > +
> > 
> >  PTX_PATCHES_HEADER="# generated by git-ptx-patches"
> >  
> >  function _md5sum() {
> > 
> > @@ -116,7 +143,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 +156,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



_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment
  2019-11-18  7:18   ` Alexander Dahl
@ 2019-11-18  9:13     ` Michael Olbrich
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Olbrich @ 2019-11-18  9:13 UTC (permalink / raw)
  To: Alexander Dahl; +Cc: ptxdist, Roland Hieber

On Mon, Nov 18, 2019 at 08:18:33AM +0100, Alexander Dahl wrote:
> Moin,
> 
> Am Sonntag, 17. November 2019, 11:31:06 CET schrieb Michael Olbrich:
> > On Mon, Nov 11, 2019 at 12:31:29PM +0100, Roland Hieber wrote:
> > > The brhaviour 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>
> > > ---
> > > 
> > >  scripts/git-ptx-patches | 31 +++++++++++++++++++++++++++++--
> > >  1 file changed, 29 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
> > > index 721aa78ba31c..63a1b3921646 100755
> > > --- a/scripts/git-ptx-patches
> > > +++ b/scripts/git-ptx-patches
> > > @@ -1,5 +1,32 @@
> > > 
> > >  #!/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.
> > > +# Maybe we need to save name and e-mail from the user config…
> > > +# Note from git-commit-tree(1): if set in the user's environment,
> > > GIT_AUTHOR_* +# and GIT_COMMITTER_* still take precedence over the user.*
> > > config variables. +PRISTINE_GIT_AUTHOR=$(git config --get user.name)
> > > +PRISTINE_GIT_EMAIL=$(git config --get user.email)
> > > +PRISTINE_GIT_PARAMS=()
> > > +if [ -n "${PRISTINE_GIT_AUTHOR}" ]; then
> > > +	PRISTINE_GIT_PARAMS+=( -c user.name="${PRISTINE_GIT_AUTHOR}" )
> > > +fi
> > > +if [ -n "${PRISTINE_GIT_EMAIL}" ]; then
> > > +	PRISTINE_GIT_PARAMS+=( -c user.email="${PRISTINE_GIT_EMAIL}" )
> > > +fi
> > 
> > I don't think we need to save user / email here.
> > git is only used for create patches, not create new commits.
> 
> I already did this, and not only once:
> 
> p --git extract foo
> cd platform-bar/build-target/foo-1.2.3
> [hack, hack, hack]
> git commit -a -m 'baz'
> git ptx-patches
> …

I do the same. But the patch only changes how git is called inside 'git
ptx-patches' and there only format-patch is used.

Michael

> > Michael
> > 
> > > +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 "${PRISTINE_GIT_PARAMS[@]}" "$@"
> > > +}
> > > +GIT="pristine_git"
> > > +
> > > 
> > >  PTX_PATCHES_HEADER="# generated by git-ptx-patches"
> > >  
> > >  function _md5sum() {
> > > 
> > > @@ -116,7 +143,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 +156,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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ptxdist] [PATCH v2] git-ptx-patches: call git in a pristine environment
  2019-11-11 11:31 [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment Roland Hieber
  2019-11-17 10:31 ` Michael Olbrich
@ 2019-11-18  9:21 ` Roland Hieber
  2019-11-18  9:32 ` [ptxdist] [PATCH v3] " Roland Hieber
  2 siblings, 0 replies; 10+ messages in thread
From: Roland Hieber @ 2019-11-18  9:21 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

The brhaviour 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>

---
v2:
 - saving author and email is not necessary for format-patch
---
 scripts/git-ptx-patches | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
index 721aa78ba31c..fe680273085b 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
-- 
2.24.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ptxdist] [PATCH v3] git-ptx-patches: call git in a pristine environment
  2019-11-11 11:31 [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment Roland Hieber
  2019-11-17 10:31 ` Michael Olbrich
  2019-11-18  9:21 ` [ptxdist] [PATCH v2] " Roland Hieber
@ 2019-11-18  9:32 ` Roland Hieber
  2019-11-18 13:39   ` Jon Ringle
  2 siblings, 1 reply; 10+ messages in thread
From: Roland Hieber @ 2019-11-18  9:32 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

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>

---
v3:
 - fix typo in the log message

v2:
 - saving author and email is not necessary for format-patch
---
 scripts/git-ptx-patches | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
index 721aa78ba31c..fe680273085b 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
-- 
2.24.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH v3] git-ptx-patches: call git in a pristine environment
  2019-11-18  9:32 ` [ptxdist] [PATCH v3] " Roland Hieber
@ 2019-11-18 13:39   ` Jon Ringle
  2019-11-27  9:41     ` Roland Hieber
  0 siblings, 1 reply; 10+ messages in thread
From: Jon Ringle @ 2019-11-18 13:39 UTC (permalink / raw)
  To: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 874 bytes --]

On Mon, Nov 18, 2019 at 4:32 AM Roland Hieber <rhi@pengutronix.de> wrote:

>
> @@ -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
>

In my own ptxdist git repo, I have a patch that adds `-M` to make file
renames less verbose. Adding this should not affect the output of any patch
series maintained by ptxdist. I needed it to make less verbose some package
I was changing locally:
git format-patch -M -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/
${range} | sed -e 's,^.ptxdist/patches/,,' > .ptxdist/series.auto

-Jon

[-- Attachment #1.2: Type: text/html, Size: 1300 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH v3] git-ptx-patches: call git in a pristine environment
  2019-11-18 13:39   ` Jon Ringle
@ 2019-11-27  9:41     ` Roland Hieber
  2019-12-05 10:15       ` Roland Hieber
  0 siblings, 1 reply; 10+ messages in thread
From: Roland Hieber @ 2019-11-27  9:41 UTC (permalink / raw)
  To: Jon Ringle; +Cc: ptxdist

On Mon, Nov 18, 2019 at 08:39:22AM -0500, Jon Ringle wrote:
> On Mon, Nov 18, 2019 at 4:32 AM Roland Hieber <rhi@pengutronix.de> wrote:
> 
> >
> > @@ -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
> >
> 
> In my own ptxdist git repo, I have a patch that adds `-M` to make file
> renames less verbose. Adding this should not affect the output of any patch
> series maintained by ptxdist. I needed it to make less verbose some package
> I was changing locally:
> git format-patch -M -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/
> ${range} | sed -e 's,^.ptxdist/patches/,,' > .ptxdist/series.auto

Does this do the right thing then even when the patches are not applied
by git during the extract stage?

 - Roland


-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ptxdist] [PATCH v3] git-ptx-patches: call git in a pristine environment
  2019-11-27  9:41     ` Roland Hieber
@ 2019-12-05 10:15       ` Roland Hieber
  0 siblings, 0 replies; 10+ messages in thread
From: Roland Hieber @ 2019-12-05 10:15 UTC (permalink / raw)
  To: ptxdist

On Wed, Nov 27, 2019 at 10:41:20AM +0100, Roland Hieber wrote:
> On Mon, Nov 18, 2019 at 08:39:22AM -0500, Jon Ringle wrote:
> > On Mon, Nov 18, 2019 at 4:32 AM Roland Hieber <rhi@pengutronix.de> wrote:
> > 
> > >
> > > @@ -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
> > >
> > 
> > In my own ptxdist git repo, I have a patch that adds `-M` to make file
> > renames less verbose. Adding this should not affect the output of any patch
> > series maintained by ptxdist. I needed it to make less verbose some package
> > I was changing locally:
> > git format-patch -M -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/
> > ${range} | sed -e 's,^.ptxdist/patches/,,' > .ptxdist/series.auto
> 
> Does this do the right thing then even when the patches are not applied
> by git during the extract stage?

In any case, adding -M to format-patch is trying to solve a different problem
than what I'm doing with my patch here, so it should be a separate patch.

Any more comments on this patch?

  - Roland

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-12-05 10:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 11:31 [ptxdist] [PATCH] git-ptx-patches: call git in a pristine environment Roland Hieber
2019-11-17 10:31 ` Michael Olbrich
2019-11-17 21:57   ` Roland Hieber
2019-11-18  7:18   ` Alexander Dahl
2019-11-18  9:13     ` Michael Olbrich
2019-11-18  9:21 ` [ptxdist] [PATCH v2] " Roland Hieber
2019-11-18  9:32 ` [ptxdist] [PATCH v3] " Roland Hieber
2019-11-18 13:39   ` Jon Ringle
2019-11-27  9:41     ` Roland Hieber
2019-12-05 10:15       ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox