mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Thorsten Scherer <T.Scherer@eckelmann.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH 1/3] git-ptx-patches: Fix a race condition
Date: Thu, 30 Nov 2023 07:09:41 +0100	[thread overview]
Message-ID: <20231130060941.fslan5ajijx5cp2w@nb821.eckelmann.group> (raw)
In-Reply-To: <20231129093743.906378-2-u.kleine-koenig@pengutronix.de>

On Wed, Nov 29, 2023 at 10:37:45AM +0100, Uwe Kleine-König wrote:
> As the loop over the output of find moves files around, it can happen
> that find lists files more than once. In that case not only the "From "
> line is removed, but also the next one (usually the "From:" line).
> 
> To process each patch in series.auto exactly once, iterate over that
> file to remove the "From " line instead. Still be a bit conservative and
> make sure that only the intended line is dropped.
> 
> Reported-by: Thorsten Scherer <t.scherer@eckelmann.de>

Tested-by: Thorsten Scherer <t.scherer@eckelmann.de>

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  scripts/git-ptx-patches | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
> index a063cb73a875..df004fb8a8a5 100755
> --- a/scripts/git-ptx-patches
> +++ b/scripts/git-ptx-patches
> @@ -221,6 +221,13 @@ cat .ptxdist/series | _md5sum >> .ptxdist/series
>  
>  # The first line of the patch is 'From <some-git-hash> ...'
>  # remove it to avoid unnecessary changes in the patch files.
> +while read patch para; do
> +	# There are no comments or empty lines in series.auto, so no need to
> +	# handle these. Also be a bit cautious to only remove lines matching
> +	# "^From ".
> +	sed -i '1{/^From /d}' ".ptxdist/patches/$patch"
> +done < .ptxdist/series.auto
> +
>  find .ptxdist/patches/ ! -type d | sed -e 's,^.ptxdist/patches/,,' | \
>  while read patch para; do
>  	case "$patch" in
> @@ -228,9 +235,8 @@ while read patch para; do
>  		*) ;;
>  	esac
>  	if grep -q "$patch" .ptxdist/series.auto; then
> -		p=".ptxdist/patches/$patch"
> -		tail -n+2 "$p" > ".$patch.ptx-patches"
> -		mv ".$patch.ptx-patches" "$p"
> +		# ok, this is one of the patches we just touched
> +		:
>  	else
>  		if grep -q "$patch" .ptxdist/series.{0,1}; then
>  			echo "Base patch \"$patch\"!"
> -- 
> 2.42.0
> 



  reply	other threads:[~2023-11-30  6:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  9:37 [ptxdist] [PATCH 0/3] git-ptx-patches: A fix and two minor improvements Uwe Kleine-König
2023-11-29  9:37 ` [ptxdist] [PATCH 1/3] git-ptx-patches: Fix a race condition Uwe Kleine-König
2023-11-30  6:09   ` Thorsten Scherer [this message]
2023-12-07 11:09   ` [ptxdist] [APPLIED] " Michael Olbrich
2023-11-29  9:37 ` [ptxdist] [PATCH 2/3] git-ptx-patches: Open .ptxdist/series less often for writing Uwe Kleine-König
2023-12-07 11:09   ` [ptxdist] [APPLIED] " Michael Olbrich
2023-11-29  9:37 ` [ptxdist] [PATCH 3/3] git-ptx-patches: Simplify nested if construct Uwe Kleine-König
2023-12-07 11:09   ` [ptxdist] [APPLIED] " Michael Olbrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231130060941.fslan5ajijx5cp2w@nb821.eckelmann.group \
    --to=t.scherer@eckelmann.de \
    --cc=ptxdist@pengutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox