From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] [pre-commit] Add check-new-file-license
Date: Wed, 17 Jun 2026 21:19:11 +0200 [thread overview]
Message-ID: <a412eeea-b057-4316-bc23-921e2b303814@suse.de> (raw)
In-Reply-To: <87a4st5adc.fsf@tromey.com>
On 6/17/26 7:45 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> I forgot to add a copyright notice to a file.
> Tom> I came across gdb/contrib/license-check-new-files.sh, and ran it out of
> Tom> curiosity, and it pointed out the file.
>
> I didn't know about this file. Weird that it has a '.sh' extension.
>
Yeah. Renaming it to .py show some pre-commit errors:
...
gdb/contrib/license-check-new-files.py:58:5: E722 do not use bare 'except'
gdb/contrib/license-check-new-files.py:106:9: E722 do not use bare 'except'
...
> Tom> Add a pre-commit check check-new-file-license that runs the script.
>
> Tom> The check is only run for new files, because it's fairly slow, about 2 seconds
> Tom> for an empty file:
>
> Hmm that really is quite slow. Is it 2 seconds per invocation or per
> new file?
>
I did an experiment with 10 empty files:
...
$ for n in $(seq 1 10); do f=gdb/bla-$n.c; touch $f; git add $f; done
$ pre-commit run check-new-file-license -v
check-new-file-license...................................................Passed
- hook id: check-new-file-license
- duration: 3.18s
gdb/bla-1.c: None
gdb/bla-10.c: None
gdb/bla-2.c: None
gdb/bla-3.c: None
gdb/bla-4.c: None
gdb/bla-5.c: None
gdb/bla-6.c: None
gdb/bla-7.c: None
gdb/bla-8.c: None
gdb/bla-9.c: None
...
So, its seems it's per invocation. If there is a significant cost per
file we could parallelize it, the current approach is serial.
An invocation without new files is fairly quick:
...
$ pre-commit run check-new-file-license -v
check-new-file-license...................................................Passed
- hook id: check-new-file-license
- duration: 0.24s
...
> Also the script seems to run git but I wonder if that's even necessary
> in this setup.
Git is used to detect the new files using a diff command.
Maybe running this directly rather than going through a git interfacing
library would be faster:
...
$ git diff --name-only --cached --diff-filter=A
...
Thanks,
- Tom
next prev parent reply other threads:[~2026-06-17 19:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 14:10 Tom de Vries
2026-06-05 18:06 ` Keith Seitz
2026-06-17 17:45 ` Tom Tromey
2026-06-17 19:19 ` Tom de Vries [this message]
2026-06-18 12:59 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a412eeea-b057-4316-bc23-921e2b303814@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox