Skip to content

Commit

Permalink
fix: util/check-format-commit.sh to handle one-line diff hunks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#24900)
  • Loading branch information
levitte committed Jul 18, 2024
1 parent cf3d65b commit 7821b7b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions util/check-format-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7821b7b

Please sign in to comment.