This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a1b13c99f715cbf95b916dee5bad64771da952e4 Author: Arjav Patel <[email protected]> AuthorDate: Mon Mar 2 21:55:52 2026 +0530 tools/checkpatch.sh: Enhance stdin support for patch checking - Added functionality to read patch content from stdin when using the '--stdin' option with the '-p' flag. - Updated usage instructions to clarify the new stdin option for patch checks. - Improved error handling for unsupported combinations of options. Signed-off-by: Arjav Patel <[email protected]> --- tools/checkpatch.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index f2865aaa0e5..a84dfc379e6 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -61,6 +61,7 @@ usage() { echo "-b Enforce breaking change format when checking commit message (requires -m -g; use when PR has breaking change label)" echo "-g <commit list>" echo " Use --stdin as the only argument with -m -g to read commit message from stdin (message-only check, no patch/diff)." + echo " Use --stdin with -p to read patch content from stdin." echo "-f <file list>" echo "-x format supported files (only .py, requires: pip install black)" echo "- read standard input mainly used by git pre-commit hook as below:" @@ -442,9 +443,25 @@ while [ ! -z "$1" ]; do done for arg in $@; do - if [ "$arg" = "--stdin" ] && [ "$check" = "check_commit" ]; then - msg=$(cat) - check_msg <<< "$msg" + if [ "$arg" = "--stdin" ]; then + case "$check" in + check_commit) + msg=$(cat) + check_msg <<< "$msg" + ;; + check_patch) + tmp=$(mktemp) + trap "rm -f $tmp" EXIT + cat > "$tmp" + check_patch "$tmp" + rm -f "$tmp" + trap - EXIT + ;; + check_file|format_file) + echo "❌ --stdin is only supported with -g (commit message) or -p (patch)" + fail=1 + ;; + esac else $check $arg fi
