* [ptxdist] [PATCH 0/3] git-ptx-patches: A fix and two minor improvements @ 2023-11-29 9:37 Uwe Kleine-König 2023-11-29 9:37 ` [ptxdist] [PATCH 1/3] git-ptx-patches: Fix a race condition Uwe Kleine-König ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Uwe Kleine-König @ 2023-11-29 9:37 UTC (permalink / raw) To: ptxdist; +Cc: Thorsten Scherer Hello, occasionally I hit the problem that git-ptx-patches removes the From: line from patches. I cannot reproduce that at will, but I think the issue is fixed in the first patch. I hit that sometimes in the past with no good idea how it could happen. Today Thorsten also hit it, which made me look into the problem again and then I spotted the issue. The other two patches are just minor improvements that I noticed while researching for the race. Best regards Uwe Uwe Kleine-König (3): git-ptx-patches: Fix a race condition git-ptx-patches: Open .ptxdist/series less often for writing git-ptx-patches: Simplify nested if construct scripts/git-ptx-patches | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) base-commit: 8d8f9a47d135920da7b70a5d71b763c457f4bcaf -- 2.42.0 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [ptxdist] [PATCH 1/3] git-ptx-patches: Fix a race condition 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 ` Uwe Kleine-König 2023-11-30 6:09 ` Thorsten Scherer 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-11-29 9:37 ` [ptxdist] [PATCH 3/3] git-ptx-patches: Simplify nested if construct Uwe Kleine-König 2 siblings, 2 replies; 8+ messages in thread From: Uwe Kleine-König @ 2023-11-29 9:37 UTC (permalink / raw) To: ptxdist; +Cc: Thorsten Scherer 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> 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ptxdist] [PATCH 1/3] git-ptx-patches: Fix a race condition 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 2023-12-07 11:09 ` [ptxdist] [APPLIED] " Michael Olbrich 1 sibling, 0 replies; 8+ messages in thread From: Thorsten Scherer @ 2023-11-30 6:09 UTC (permalink / raw) To: Uwe Kleine-König; +Cc: ptxdist 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 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ptxdist] [APPLIED] git-ptx-patches: Fix a race condition 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 @ 2023-12-07 11:09 ` Michael Olbrich 1 sibling, 0 replies; 8+ messages in thread From: Michael Olbrich @ 2023-12-07 11:09 UTC (permalink / raw) To: ptxdist; +Cc: Uwe Kleine-König Thanks, applied as 53de5f3e2e53582238bbd594aaa4749549672fb6. Michael [sent from post-receive hook] On Thu, 07 Dec 2023 12:09:52 +0100, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> 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> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Tested-by: Thorsten Scherer <t.scherer@eckelmann.de> > Message-Id: <20231129093743.906378-2-u.kleine-koenig@pengutronix.de> > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> > > 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\"!" ^ permalink raw reply [flat|nested] 8+ messages in thread
* [ptxdist] [PATCH 2/3] git-ptx-patches: Open .ptxdist/series less often for writing 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-29 9:37 ` 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 2 siblings, 1 reply; 8+ messages in thread From: Uwe Kleine-König @ 2023-11-29 9:37 UTC (permalink / raw) To: ptxdist; +Cc: Thorsten Scherer Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- scripts/git-ptx-patches | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches index df004fb8a8a5..56e82eb2ee56 100755 --- a/scripts/git-ptx-patches +++ b/scripts/git-ptx-patches @@ -204,7 +204,6 @@ 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} | while read patch; do if "$numbered_patches"; then patchname="${patch#.ptxdist/patches/}" @@ -215,8 +214,7 @@ ${GIT} format-patch -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/ ${range} | echo "$patchname" done > .ptxdist/series.auto -cat .ptxdist/series.auto >> .ptxdist/series -cat .ptxdist/series.1 >> .ptxdist/series +cat .ptxdist/series.0 .ptxdist/series.auto .ptxdist/series.1 > .ptxdist/series cat .ptxdist/series | _md5sum >> .ptxdist/series # The first line of the patch is 'From <some-git-hash> ...' -- 2.42.0 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ptxdist] [APPLIED] git-ptx-patches: Open .ptxdist/series less often for writing 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 ` Michael Olbrich 0 siblings, 0 replies; 8+ messages in thread From: Michael Olbrich @ 2023-12-07 11:09 UTC (permalink / raw) To: ptxdist; +Cc: Uwe Kleine-König Thanks, applied as cda14c096bdf91154b3fb2485bd7d5d373fb6c8d. Michael [sent from post-receive hook] On Thu, 07 Dec 2023 12:09:52 +0100, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Message-Id: <20231129093743.906378-3-u.kleine-koenig@pengutronix.de> > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> > > diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches > index df004fb8a8a5..56e82eb2ee56 100755 > --- a/scripts/git-ptx-patches > +++ b/scripts/git-ptx-patches > @@ -204,7 +204,6 @@ 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} | while read patch; do > if "$numbered_patches"; then > patchname="${patch#.ptxdist/patches/}" > @@ -215,8 +214,7 @@ ${GIT} format-patch -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/ ${range} | > echo "$patchname" > done > .ptxdist/series.auto > > -cat .ptxdist/series.auto >> .ptxdist/series > -cat .ptxdist/series.1 >> .ptxdist/series > +cat .ptxdist/series.0 .ptxdist/series.auto .ptxdist/series.1 > .ptxdist/series > cat .ptxdist/series | _md5sum >> .ptxdist/series > > # The first line of the patch is 'From <some-git-hash> ...' ^ permalink raw reply [flat|nested] 8+ messages in thread
* [ptxdist] [PATCH 3/3] git-ptx-patches: Simplify nested if construct 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-29 9:37 ` [ptxdist] [PATCH 2/3] git-ptx-patches: Open .ptxdist/series less often for writing Uwe Kleine-König @ 2023-11-29 9:37 ` Uwe Kleine-König 2023-12-07 11:09 ` [ptxdist] [APPLIED] " Michael Olbrich 2 siblings, 1 reply; 8+ messages in thread From: Uwe Kleine-König @ 2023-11-29 9:37 UTC (permalink / raw) To: ptxdist; +Cc: Thorsten Scherer Instead of if A; then ... else if B; then ... else ... fi fi use the more compact if A; then ... elif B; then ... else ... fi Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- scripts/git-ptx-patches | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches index 56e82eb2ee56..b27dbe7905d9 100755 --- a/scripts/git-ptx-patches +++ b/scripts/git-ptx-patches @@ -235,11 +235,9 @@ while read patch para; do if grep -q "$patch" .ptxdist/series.auto; then # ok, this is one of the patches we just touched : + elif grep -q "$patch" .ptxdist/series.{0,1}; then + echo "Base patch \"$patch\"!" else - if grep -q "$patch" .ptxdist/series.{0,1}; then - echo "Base patch \"$patch\"!" - else - echo "Old patch \"$patch\"!" - fi + echo "Old patch \"$patch\"!" fi done | sort -- 2.42.0 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ptxdist] [APPLIED] git-ptx-patches: Simplify nested if construct 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 ` Michael Olbrich 0 siblings, 0 replies; 8+ messages in thread From: Michael Olbrich @ 2023-12-07 11:09 UTC (permalink / raw) To: ptxdist; +Cc: Uwe Kleine-König Thanks, applied as 5b1b2174fcad766c495d8bbbd5b2216cafe4fa64. Michael [sent from post-receive hook] On Thu, 07 Dec 2023 12:09:53 +0100, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > Instead of > > if A; then > ... > else > if B; then > ... > else > ... > fi > fi > > use the more compact > > if A; then > ... > elif B; then > ... > else > ... > fi > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Message-Id: <20231129093743.906378-4-u.kleine-koenig@pengutronix.de> > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> > > diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches > index 56e82eb2ee56..b27dbe7905d9 100755 > --- a/scripts/git-ptx-patches > +++ b/scripts/git-ptx-patches > @@ -235,11 +235,9 @@ while read patch para; do > if grep -q "$patch" .ptxdist/series.auto; then > # ok, this is one of the patches we just touched > : > + elif grep -q "$patch" .ptxdist/series.{0,1}; then > + echo "Base patch \"$patch\"!" > else > - if grep -q "$patch" .ptxdist/series.{0,1}; then > - echo "Base patch \"$patch\"!" > - else > - echo "Old patch \"$patch\"!" > - fi > + echo "Old patch \"$patch\"!" > fi > done | sort ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-07 11:10 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox