From 430d2990c68c5613297421302106be1dec997adb Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 16 Jul 2024 05:28:30 +0200 Subject: [PATCH] fix: util/check-format-commit.sh to handle one-line diff hunks For multi-line hunks, 'git diff -U0' outputs a pair of START,COUNT indicators to show where the hunk starts and ends. However, if the hunk is just one line, only START is output, with the COUNT of 1 being implied. Typically, this happens for copyright change hunks, like this: --- a/crypto/evp/evp_err.c +++ b/crypto/evp/evp_err.c @@ -3 +3 @@ - * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. This is normal unified diff output, and our script must adapt. Reviewed-by: Tom Cosgrove Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/24900) (cherry picked from commit 7821b7b9774d481ae92610e2d132ea34d4aaf407) --- util/check-format-commit.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/check-format-commit.sh b/util/check-format-commit.sh index 35495fce63f..d1b344f16d3 100755 --- a/util/check-format-commit.sh +++ b/util/check-format-commit.sh @@ -130,6 +130,8 @@ do RANGE=$k RSTART=$(echo $RANGE | awk -F',' '{print $1}') RLEN=$(echo $RANGE | awk -F',' '{print $2}') + # when the hunk is just one line, its length is implied + if [ -z "$RLEN" ]; then RLEN=1; fi let REND=$RSTART+$RLEN range_start+=($RSTART) range_end+=($REND) -- 2.47.2