From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 29 Nov 2023 10:38:34 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r8H1e-00D4xD-0s for lore@lore.pengutronix.de; Wed, 29 Nov 2023 10:38:34 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1r8H1e-0003OX-Kf; Wed, 29 Nov 2023 10:38:34 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r8H15-00039x-29; Wed, 29 Nov 2023 10:37:59 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8H14-00CNDr-Lw; Wed, 29 Nov 2023 10:37:58 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r8H14-00AkLy-Cd; Wed, 29 Nov 2023 10:37:58 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: ptxdist@pengutronix.de Date: Wed, 29 Nov 2023 10:37:45 +0100 Message-ID: <20231129093743.906378-2-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231129093743.906378-1-u.kleine-koenig@pengutronix.de> References: <20231129093743.906378-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1784; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=nw6r49s4nRYw4Jcm+dABWEQRe0Yt+IrtstURB//96Ag=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlZwZoFXXTIZ3TESEMY44G/KBJrIBkXxWyk5xXZ sGTFYWPg5qJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZWcGaAAKCRCPgPtYfRL+ Tv6ACACoqFoblB9ceWlfjJ9Y9PXMizVf2kurFEiUtk6pfItkTemlKesbvZU9eTzQ1vF87ScbcuB 4CtGa/qlAIpXGfzxfOTaotir9wjuJ7lDr2czU8IZ5uJbHX9qg/g2n4XBlft0YyI9R7VlieR+kuQ Se6hmVCAOLOhaX2LR8riJepp0XLBkFppQpBvE8934mliuayuPY2ysnxLWuGV1wr7faW3YFvSypr +HyoGxRj3RyqtoKw7Mv2U0V8RkvbgG/+wrgf9BWS0Q3DYw4iFoXTQBUr/Scqi97vLvHbpbyHs1O pRq8mI/Fch+CUpTMadgNHYu56uy/L9vopjwWoQDFjN94XX1I X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit Subject: [ptxdist] [PATCH 1/3] git-ptx-patches: Fix a race condition X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: Thorsten Scherer Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false 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 Signed-off-by: Uwe Kleine-König --- 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 ...' # 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