DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] devtools: honor -n flag regardless of stdin state
@ 2025-10-14  7:43 Ali Alnubani
  2025-10-23 14:33 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Ali Alnubani @ 2025-10-14  7:43 UTC (permalink / raw)
  To: dev

The checkpatches.sh script was checking if stdin is a terminal before
honoring the -n flag, causing it to incorrectly attempt to read patches
from stdin when run without a TTY (e.g., in Jenkins/CI pipelines).

Reorder the conditionals to check for the -n flag before checking stdin
state. This ensures the -n flag takes precedence and the script checks
git commits as intended.

Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
---
 devtools/checkpatches.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 9fb8fd0a07..0884f24839 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -558,9 +558,7 @@ if [ -n "$1" ] ; then
 	for patch in "$@" ; do
 		check "$patch" ''
 	done
-elif [ ! -t 0 ] ; then # stdin
-	check '' ''
-else
+elif [ $number -ne 0 ] || [ -t 0 ]; then
 	if [ $number -eq 0 ] ; then
 		commits=$(git rev-list --reverse $range)
 	else
@@ -569,6 +567,8 @@ else
 	for commit in $commits ; do
 		check '' $commit
 	done
+else # stdin
+	check '' ''
 fi
 pass=$(($total - $status))
 $quiet || printf '\n%d/%d valid patch' $pass $total
-- 
2.43.0


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

* Re: [PATCH] devtools: honor -n flag regardless of stdin state
  2025-10-14  7:43 [PATCH] devtools: honor -n flag regardless of stdin state Ali Alnubani
@ 2025-10-23 14:33 ` Thomas Monjalon
  2025-10-23 14:51   ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2025-10-23 14:33 UTC (permalink / raw)
  To: Ali Alnubani; +Cc: dev

14/10/2025 09:43, Ali Alnubani:
> The checkpatches.sh script was checking if stdin is a terminal before
> honoring the -n flag, causing it to incorrectly attempt to read patches
> from stdin when run without a TTY (e.g., in Jenkins/CI pipelines).
> 
> Reorder the conditionals to check for the -n flag before checking stdin
> state. This ensures the -n flag takes precedence and the script checks
> git commits as intended.
> 
> Signed-off-by: Ali Alnubani <alialnu@nvidia.com>

Applied, thanks.



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

* Re: [PATCH] devtools: honor -n flag regardless of stdin state
  2025-10-23 14:33 ` Thomas Monjalon
@ 2025-10-23 14:51   ` Thomas Monjalon
  2025-11-28 14:40     ` [PATCH v2] devtools: check patch from stdin only if nothing else Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2025-10-23 14:51 UTC (permalink / raw)
  To: Ali Alnubani; +Cc: dev

23/10/2025 16:33, Thomas Monjalon:
> 14/10/2025 09:43, Ali Alnubani:
> > The checkpatches.sh script was checking if stdin is a terminal before
> > honoring the -n flag, causing it to incorrectly attempt to read patches
> > from stdin when run without a TTY (e.g., in Jenkins/CI pipelines).
> > 
> > Reorder the conditionals to check for the -n flag before checking stdin
> > state. This ensures the -n flag takes precedence and the script checks
> > git commits as intended.
> > 
> > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> 
> Applied, thanks.

After a second thought, I did not push it
as I think we should improve the check to make
the option -r a priority as well.
Then the title would become "check patch from stdin only if nothing else".



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

* [PATCH v2] devtools: check patch from stdin only if nothing else
  2025-10-23 14:51   ` Thomas Monjalon
@ 2025-11-28 14:40     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2025-11-28 14:40 UTC (permalink / raw)
  To: dev; +Cc: Ali Alnubani

From: Ali Alnubani <alialnu@nvidia.com>

The checkpatches.sh script was checking if stdin is a terminal before
honoring the -n flag, causing it to incorrectly attempt to read patches
from stdin when run without a TTY (e.g., in Jenkins/CI pipelines).

Reorder the conditionals to check for the -n and -r flags
before checking stdin state.
This ensures the -n/-r flags takes precedence
and the script checks git commits as intended.

Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2: make also -r a priority (before considering stdin)
---
 devtools/checkpatches.sh | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 9fb8fd0a07..47e8ca57b4 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -421,8 +421,8 @@ check_release_notes() { # <patch>
 		grep -v $current_rel_notes
 }
 
-number=0
-range='origin/main..'
+number=
+range=
 quiet=false
 verbose=false
 while getopts hn:qr:v ARG ; do
@@ -558,17 +558,20 @@ if [ -n "$1" ] ; then
 	for patch in "$@" ; do
 		check "$patch" ''
 	done
-elif [ ! -t 0 ] ; then # stdin
-	check '' ''
-else
-	if [ $number -eq 0 ] ; then
-		commits=$(git rev-list --reverse $range)
-	else
+elif [ -n "$number" ] || [ -n "$range" ] || [ -t 0 ]; then
+	if [ -n "$number" ] ; then
 		commits=$(git rev-list --reverse --max-count=$number HEAD)
+	else
+		if [ -z "$range" ] ; then
+			range='origin/main..' # default
+		fi
+		commits=$(git rev-list --reverse $range)
 	fi
 	for commit in $commits ; do
 		check '' $commit
 	done
+else # stdin
+	check '' ''
 fi
 pass=$(($total - $status))
 $quiet || printf '\n%d/%d valid patch' $pass $total
-- 
2.51.0


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

end of thread, other threads:[~2025-11-28 14:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-14  7:43 [PATCH] devtools: honor -n flag regardless of stdin state Ali Alnubani
2025-10-23 14:33 ` Thomas Monjalon
2025-10-23 14:51   ` Thomas Monjalon
2025-11-28 14:40     ` [PATCH v2] devtools: check patch from stdin only if nothing else Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).