devtools: honor -n flag regardless of stdin state
PATCH 1/1 devtools: honor -n flag regardless of stdin state
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.
--- devtools/checkpatches.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
devtools/checkpatches.sh +3 -3
@@ -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
Signature · 1 line
2.43.0
Thomas Monjalon
Applied14/10/2025 09:43, Ali Alnubani:
Quoted 9 lines
The
checkpatches.shscript 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 <[email protected]>
Applied, thanks.
23/10/2025 16:33, Thomas Monjalon:
Quoted 5 lines
14/10/2025 09:43, Ali Alnubani:
Quoted 4 lines
The
checkpatches.shscript 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).
Quoted 7 lines
Quoted 5 lines
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 <[email protected]>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".
PATCH v2 1/1 devtools: check patch from stdin only if nothing else
From: Ali Alnubani <[email protected]>
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.
---
v2: make also -r a priority (before considering stdin)
--- devtools/checkpatches.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
devtools/checkpatches.sh +11 -8
@@ -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
Signature · 1 line
2.51.0
Thomas Monjalon
AppliedRe: [PATCH v2] devtools: check patch from stdin only if nothing else
28/11/2025 15:40, Thomas Monjalon:
Quoted 6 lines
From: Ali Alnubani <[email protected]>
The
checkpatches.shscript 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).
Quoted 7 lines
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 <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
Applied