Hi Ilya,
On 6/19/26 10:19 PM, Ilya Maximets wrote:
> On 6/19/26 9:44 AM, Dumitru Ceara via dev wrote:
>> The pre-push example hook was suggesting the usage of:
>>
>> checkpatch.py -1 $sha
>>
>> That is incorrect, checkpatch.py will then only check the last commit on
>> the current branch, i.e., only the "-1" argument is enforced. Moreover,
>> `checkpatch.py $sha` is also wrong, it would fail with:
>>
>> ERROR: Unable to parse file '<SHA>'. Is it a patch?
>>
>> A better way seems to be:
>>
>> git format-patch -1 --stdout $sha | checkpatch.py
>
> This one is also not bulletproof. The format-patch with the
> default pretty format wraps the subject lines messing up the
> subject line checks. We'll need to add the format string to
> make that work properly or enhance the checkpatch itself to
> accept sha.
>
Ah, my bad, I missed that.
> We also need to call ./utilities/checkpatch.py instead of plain
> checkpatch.py, AFAIU.
>
That's maybe true. However, I never run the checkpatch.py script that's
part of the tree but instead I run a private copy of it. Just in case
stuff creeped into the in-tree script with me missing it. That's why
I messed up the relative path here.
I can update it though.
I was thinking of something like this as alternative but then you
lose the interleaved git log + checkpatch:
diff --git a/Documentation/internals/committer-responsibilities.rst
b/Documentation/internals/committer-responsibilities.rst
index 63acec42f8ae..c7f091452104 100644
--- a/Documentation/internals/committer-responsibilities.rst
+++ b/Documentation/internals/committer-responsibilities.rst
@@ -119,16 +119,9 @@ in your ``.git`` directory and make sure to mark it as
executable with
while read local_ref local_sha1 remote_ref remote_sha1; do
case $remote_ref in
refs/heads/main)
- n=0
- while read sha
- do
- n=$(expr $n + 1)
- git log -1 $sha
- echo
- git format-patch -1 --stdout $sha | checkpatch.py
- done <<EOF
- $(git --no-pager log --pretty=%H $local_sha1...$remote_sha1)
- EOF
+ n=$(git --no-pager log --pretty=%H $local_sha1...$remote_sha1 |
wc -l)
+ git log -$n
+ ./utilities/checkpatch.py -$n
b=${remote_ref#refs/heads/}
echo "You're about to push $n commits to protected branch $b on
$remote."
---
Adding the custom format string works too but looks quite bad. :)
diff --git a/Documentation/internals/committer-responsibilities.rst
b/Documentation/internals/committer-responsibilities.rst
index 63acec42f8ae..96aaba4d79f5 100644
--- a/Documentation/internals/committer-responsibilities.rst
+++ b/Documentation/internals/committer-responsibilities.rst
@@ -119,13 +119,17 @@ in your ``.git`` directory and make sure to mark it as
executable with
while read local_ref local_sha1 remote_ref remote_sha1; do
case $remote_ref in
refs/heads/main)
- n=0
while read sha
do
n=$(expr $n + 1)
git log -1 $sha
echo
- git format-patch -1 --stdout $sha | checkpatch.py
+ git format-patch -1 --stdout --pretty=format:"\
+Author: %an <%ae>
+Commit: %cn <%ce>
+Subject: %s
+
+%b" $sha | ./utilities/checkpatch.py
done <<EOF
$(git --no-pager log --pretty=%H $local_sha1...$remote_sha1)
EOF
---
I could also look at enhancing checkpatch but OTOH this is a one time
configuration in the maintainer's pre-push hook so I don't know if
that's really worth it. Maybe I should just accept the "ugly"
pretty format args.
I'll wait for feedback before v2.
Thanks a lot for the review!
Regards,
Dumitru
> Best regards, Ilya Maximets.
>
>>
>> Update the docs to reflect that.
>>
>> Signed-off-by: Dumitru Ceara <[email protected]>
>> ---
>> Documentation/internals/committer-responsibilities.rst | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/Documentation/internals/committer-responsibilities.rst
>> b/Documentation/internals/committer-responsibilities.rst
>> index eed2e017678a..63acec42f8ae 100644
>> --- a/Documentation/internals/committer-responsibilities.rst
>> +++ b/Documentation/internals/committer-responsibilities.rst
>> @@ -125,7 +125,7 @@ in your ``.git`` directory and make sure to mark it as
>> executable with
>> n=$(expr $n + 1)
>> git log -1 $sha
>> echo
>> - checkpatch.py -1 $sha
>> + git format-patch -1 --stdout $sha | checkpatch.py
>> done <<EOF
>> $(git --no-pager log --pretty=%H $local_sha1...$remote_sha1)
>> EOF
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev