[PATCH 5/9] scripts/clean-includes: Give the args in git commit messages

Peter Maydell posted 9 patches 1 week, 4 days ago
Maintainers: Jonathan Cameron <jonathan.cameron@huawei.com>, Fan Ni <fan.ni@samsung.com>, John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, "Cédric Le Goater" <clg@redhat.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Jason Herne <jjherne@linux.ibm.com>, Alex Williamson <alex@shazbot.org>, Thomas Huth <thuth@redhat.com>, Steve Sistare <steven.sistare@oracle.com>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Nicholas Piggin <npiggin@gmail.com>, Aditya Gupta <adityag@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>, "Daniel P. Berrangé" <berrange@redhat.com>
[PATCH 5/9] scripts/clean-includes: Give the args in git commit messages
Posted by Peter Maydell 1 week, 4 days ago
If clean-includes is creating a git commit for its changes,
currently it says only "created with scripts/clean-includes".
Add the command line arguments the user passed us, as useful
extra information.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 scripts/clean-includes | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/clean-includes b/scripts/clean-includes
index a45421d2ff7..694e12f062c 100755
--- a/scripts/clean-includes
+++ b/scripts/clean-includes
@@ -42,6 +42,9 @@
 GIT=no
 DUPHEAD=no
 
+# Save the original arguments in case we want to put them in
+# a git commit message
+ORIGARGS="$*"
 
 while true
 do
@@ -198,7 +201,8 @@ if [ "$GIT" = "yes" ]; then
     git commit --signoff -F - <<EOF
 $GITSUBJ: Clean up includes
 
-This commit was created with scripts/clean-includes.
+This commit was created with scripts/clean-includes:
+ ./scripts/clean-includes $ORIGARGS
 
 All .c should include qemu/osdep.h first.  The script performs three
 related cleanups:
-- 
2.43.0
Re: [PATCH 5/9] scripts/clean-includes: Give the args in git commit messages
Posted by Markus Armbruster 1 week, 1 day ago
Peter Maydell <peter.maydell@linaro.org> writes:

> If clean-includes is creating a git commit for its changes,
> currently it says only "created with scripts/clean-includes".
> Add the command line arguments the user passed us, as useful
> extra information.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  scripts/clean-includes | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/clean-includes b/scripts/clean-includes
> index a45421d2ff7..694e12f062c 100755
> --- a/scripts/clean-includes
> +++ b/scripts/clean-includes
> @@ -42,6 +42,9 @@
>  GIT=no
>  DUPHEAD=no
>  
> +# Save the original arguments in case we want to put them in
> +# a git commit message
> +ORIGARGS="$*"
>  
>  while true
>  do
> @@ -198,7 +201,8 @@ if [ "$GIT" = "yes" ]; then
>      git commit --signoff -F - <<EOF
>  $GITSUBJ: Clean up includes
>  
> -This commit was created with scripts/clean-includes.
> +This commit was created with scripts/clean-includes:
> + ./scripts/clean-includes $ORIGARGS

Consider

    $ ./scripts/clean-includes --git 'a b c' a b c

>  
>  All .c should include qemu/osdep.h first.  The script performs three
>  related cleanups:
Re: [PATCH 5/9] scripts/clean-includes: Give the args in git commit messages
Posted by Peter Maydell 1 week, 1 day ago
On Fri, 7 Nov 2025 at 12:05, Markus Armbruster <armbru@redhat.com> wrote:
>
> Peter Maydell <peter.maydell@linaro.org> writes:
>
> > If clean-includes is creating a git commit for its changes,
> > currently it says only "created with scripts/clean-includes".
> > Add the command line arguments the user passed us, as useful
> > extra information.
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> >  scripts/clean-includes | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/clean-includes b/scripts/clean-includes
> > index a45421d2ff7..694e12f062c 100755
> > --- a/scripts/clean-includes
> > +++ b/scripts/clean-includes
> > @@ -42,6 +42,9 @@
> >  GIT=no
> >  DUPHEAD=no
> >
> > +# Save the original arguments in case we want to put them in
> > +# a git commit message
> > +ORIGARGS="$*"
> >
> >  while true
> >  do
> > @@ -198,7 +201,8 @@ if [ "$GIT" = "yes" ]; then
> >      git commit --signoff -F - <<EOF
> >  $GITSUBJ: Clean up includes
> >
> > -This commit was created with scripts/clean-includes.
> > +This commit was created with scripts/clean-includes:
> > + ./scripts/clean-includes $ORIGARGS
>
> Consider
>
>     $ ./scripts/clean-includes --git 'a b c' a b c

Yes. Do you have a way to deal with that that isn't
more complex than justified by what we're doing here?

thanks
-- PMM
Re: [PATCH 5/9] scripts/clean-includes: Give the args in git commit messages
Posted by Markus Armbruster 1 week, 1 day ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On Fri, 7 Nov 2025 at 12:05, Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>> > If clean-includes is creating a git commit for its changes,
>> > currently it says only "created with scripts/clean-includes".
>> > Add the command line arguments the user passed us, as useful
>> > extra information.
>> >
>> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> > ---
>> >  scripts/clean-includes | 6 +++++-
>> >  1 file changed, 5 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/scripts/clean-includes b/scripts/clean-includes
>> > index a45421d2ff7..694e12f062c 100755
>> > --- a/scripts/clean-includes
>> > +++ b/scripts/clean-includes
>> > @@ -42,6 +42,9 @@
>> >  GIT=no
>> >  DUPHEAD=no
>> >
>> > +# Save the original arguments in case we want to put them in
>> > +# a git commit message
>> > +ORIGARGS="$*"
>> >
>> >  while true
>> >  do
>> > @@ -198,7 +201,8 @@ if [ "$GIT" = "yes" ]; then
>> >      git commit --signoff -F - <<EOF
>> >  $GITSUBJ: Clean up includes
>> >
>> > -This commit was created with scripts/clean-includes.
>> > +This commit was created with scripts/clean-includes:
>> > + ./scripts/clean-includes $ORIGARGS
>>
>> Consider
>>
>>     $ ./scripts/clean-includes --git 'a b c' a b c
>
> Yes. Do you have a way to deal with that that isn't
> more complex than justified by what we're doing here?
>
> thanks
> -- PMM

This doesn't feel too onerous:

    args=
    for i
    do args+=" '""$i""'"
    done

However, += is bash.
Re: [PATCH 5/9] scripts/clean-includes: Give the args in git commit messages
Posted by Markus Armbruster 1 week, 1 day ago
Markus Armbruster <armbru@redhat.com> writes:

> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On Fri, 7 Nov 2025 at 12:05, Markus Armbruster <armbru@redhat.com> wrote:
>>>
>>> Peter Maydell <peter.maydell@linaro.org> writes:
>>>
>>> > If clean-includes is creating a git commit for its changes,
>>> > currently it says only "created with scripts/clean-includes".
>>> > Add the command line arguments the user passed us, as useful
>>> > extra information.
>>> >
>>> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> > ---
>>> >  scripts/clean-includes | 6 +++++-
>>> >  1 file changed, 5 insertions(+), 1 deletion(-)
>>> >
>>> > diff --git a/scripts/clean-includes b/scripts/clean-includes
>>> > index a45421d2ff7..694e12f062c 100755
>>> > --- a/scripts/clean-includes
>>> > +++ b/scripts/clean-includes
>>> > @@ -42,6 +42,9 @@
>>> >  GIT=no
>>> >  DUPHEAD=no
>>> >
>>> > +# Save the original arguments in case we want to put them in
>>> > +# a git commit message
>>> > +ORIGARGS="$*"
>>> >
>>> >  while true
>>> >  do
>>> > @@ -198,7 +201,8 @@ if [ "$GIT" = "yes" ]; then
>>> >      git commit --signoff -F - <<EOF
>>> >  $GITSUBJ: Clean up includes
>>> >
>>> > -This commit was created with scripts/clean-includes.
>>> > +This commit was created with scripts/clean-includes:
>>> > + ./scripts/clean-includes $ORIGARGS
>>>
>>> Consider
>>>
>>>     $ ./scripts/clean-includes --git 'a b c' a b c
>>
>> Yes. Do you have a way to deal with that that isn't
>> more complex than justified by what we're doing here?
>>
>> thanks
>> -- PMM
>
> This doesn't feel too onerous:
>
>     args=
>     for i
>     do args+=" '""$i""'"
>     done
>
> However, += is bash.

Have a look at configure:

    printf "exec" >>config.status
    for i in "$0" "$@"; do
      test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
    done

with shell function

    quote_sh() {
        printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
    }