From: Joe Perches <joe@perches.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Kosina <trivial@kernel.org>
Subject: git grep/sed to standardize "/* SPDX-License-Identifier: <license>"
Date: Tue, 06 Oct 2020 16:13:03 -0700 [thread overview]
Message-ID: <307a7581abe24135ac243c3080d4ab9e7c044cbf.camel@perches.com> (raw)
Almost all source files in the kernel use a standardized SPDX header
at line 1 with a comment /* initiator and terminator */:
/* SPDX-License-Identifier: <license> */
$ git grep -PHn '^/\* SPDX-License-Identifier:.*\*/\s*$' | \
wc -l
17847
$ git grep -PHn '^/\* SPDX-License-Identifier:.*\*/\s*$' | \
grep ":1:" | cut -f1 -d":" | grep -oP '\.\w+$' | \
sort | uniq -c | sort -rn
16769 .h
972 .S
87 .c
6 .lds
3 .l
2 .y
2 .py
2 .dtsi
1 .sh
1 .dts
1 .cpp
1 .bc
But about 2% of the files do not use a use comment termination at
line 1 and use either:
/* SPDX-License-Identifier: <license>
* additional comment or blank
or
/* SPDX-License-Identifier: <license>
<blank line>
$ git grep -PHn '^/\* SPDX-License-Identifier:(?!.*\*/\s*$)' | \
wc -l
407
$ git grep -PHn '^/\* SPDX-License-Identifier:(?!.*\*/\s*$)' | \
grep '\:1:' | cut -f1 -d':' | grep -oP '\.\w+$' | \
sort | uniq -c | sort -rn
357 .h
34 .S
16 .c
Here's a trivial script to convert and standardize the
first and second lines of these 407 files to make it easier
to categorize and sort.
$ git grep -PHn '^/\* SPDX-License-Identifier:(?!.*\*/\s*$)' | \
grep ':1:' | cut -f1 -d":" | \
xargs sed -i -e '1s@[[:space:]]*$@ */@' -r -e '2s@^( \*|)@/*@'
next reply other threads:[~2020-10-06 23:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-06 23:13 Joe Perches [this message]
2020-10-11 18:42 ` Linus Torvalds
2020-10-11 18:47 ` Joe Perches
2020-10-11 20:29 ` Joe Perches
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=307a7581abe24135ac243c3080d4ab9e7c044cbf.camel@perches.com \
--to=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=trivial@kernel.org \
/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
all inboxes | Powered by JetHome®