diff mbox series

[v2,2/2] Documentation: best practices for using Link trailers

Message ID 20240619-docs-patch-msgid-link-v2-2-72dd272bfe37@linuxfoundation.org (mailing list archive)
State Not Applicable
Headers show
Series Documentation: update information for mailing lists | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Konstantin Ryabitsev June 19, 2024, 6:24 p.m. UTC
Based on multiple conversations, most recently on the ksummit mailing
list [1], add some best practices for using the Link trailer, such as:

- how to use markdown-like bracketed numbers in the commit message to
indicate the corresponding link
- when to use lore.kernel.org vs patch.msgid.link domains

Cc: ksummit@lists.linux.dev
Link: https://lore.kernel.org/20240617-arboreal-industrious-hedgehog-5b84ae@meerkat # [1]
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
---
 Documentation/process/maintainer-tip.rst | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

Comments

Michael S. Tsirkin June 21, 2024, 10:34 a.m. UTC | #1
On Wed, Jun 19, 2024 at 02:24:07PM -0400, Konstantin Ryabitsev wrote:
> Based on multiple conversations, most recently on the ksummit mailing
> list [1], add some best practices for using the Link trailer, such as:
> 
> - how to use markdown-like bracketed numbers in the commit message to
> indicate the corresponding link
> - when to use lore.kernel.org vs patch.msgid.link domains
> 
> Cc: ksummit@lists.linux.dev
> Link: https://lore.kernel.org/20240617-arboreal-industrious-hedgehog-5b84ae@meerkat # [1]
> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
> ---
>  Documentation/process/maintainer-tip.rst | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/process/maintainer-tip.rst b/Documentation/process/maintainer-tip.rst
> index 64739968afa6..ba312345d030 100644
> --- a/Documentation/process/maintainer-tip.rst
> +++ b/Documentation/process/maintainer-tip.rst
> @@ -372,17 +372,31 @@ following tag ordering scheme:
>  
>   - Link: ``https://link/to/information``
>  
> -   For referring to an email on LKML or other kernel mailing lists,
> -   please use the lore.kernel.org redirector URL::
> +   For referring to an email posted to the kernel mailing lists, please
> +   use the lore.kernel.org redirector URL::
>  
> -     https://lore.kernel.org/r/email-message@id
> +     Link: https://lore.kernel.org/email-message-id@here
>  
> -   The kernel.org redirector is considered a stable URL, unlike other email
> -   archives.
> +   This URL should be used when referring to relevant mailing list
> +   topics, related patch sets, or other notable discussion threads.
> +   A convenient way to associate ``Link:`` trailers with the commit
> +   message is to use markdown-like bracketed notation, for example::
>  
> -   Maintainers will add a Link tag referencing the email of the patch
> -   submission when they apply a patch to the tip tree. This tag is useful
> -   for later reference and is also used for commit notifications.
> +     A similar approach was attempted before as part of a different
> +     effort [1], but the initial implementation caused too many
> +     regressions [2], so it was backed out and reimplemented.
> +
> +     Link: https://lore.kernel.org/some-msgid@here # [1]
> +     Link: https://bugzilla.example.org/bug/12345  # [2]
> +
> +   You can also use ``Link:`` trailers to indicate the origin of the
> +   patch when applying it to your git tree. In that case, please use the
> +   dedicated ``patch.msgid.link`` domain instead of ``lore.kernel.org``.
> +   This practice makes it possible for automated tooling to identify
> +   which link to use to retrieve the original patch submission. For
> +   example::
> +
> +     Link: https://patch.msgid.link/patch-source-message-id@here
>  
>  Please do not use combined tags, e.g. ``Reported-and-tested-by``, as
>  they just complicate automated extraction of tags.

Could you please add a hint on configuring git am to create these?

I think something like this in .git/hooks/applypatch-msg will work:

. git-sh-setup
perl -pi -e 's|^Message-Id:\s*<?([^>]+)>?$|Link: https://patch.msgid.link/$1|g;' "$1"
test -x "$GIT_DIR/hooks/commit-msg" &&
        exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
:

but I didn't actually try.

Thanks!

> -- 
> 2.45.2
>
Kees Cook June 21, 2024, 9:07 p.m. UTC | #2
On Wed, Jun 19, 2024 at 02:24:07PM -0400, Konstantin Ryabitsev wrote:
> +   This URL should be used when referring to relevant mailing list
> +   topics, related patch sets, or other notable discussion threads.
> +   A convenient way to associate ``Link:`` trailers with the commit
> +   message is to use markdown-like bracketed notation, for example::
> ...
> +     Link: https://lore.kernel.org/some-msgid@here # [1]
> +     Link: https://bugzilla.example.org/bug/12345  # [2]

Why are we adding the extra "# " characters? The vast majority of
existing Link tags don't do this:

$ git log --grep Link: | grep 'Link:.*\[' > links.txt
$ wc -l links.txt
1687 links.txt

# Link: URL... [1]
$ grep 'Link: .*[^#] \[' links.txt | wc -l
1546

# Link: URL... # [1]
$ grep 'Link: .* # \[' links.txt | wc -l
83

# Link: [1] URL...
$ grep 'Link: \[' links.txt | wc -l
44

# Link: URL... [#1]
$ grep 'Link: .*\[#' links.txt | wc -l
12
Konstantin Ryabitsev June 21, 2024, 9:37 p.m. UTC | #3
On Fri, Jun 21, 2024 at 02:07:44PM GMT, Kees Cook wrote:
> On Wed, Jun 19, 2024 at 02:24:07PM -0400, Konstantin Ryabitsev wrote:
> > +   This URL should be used when referring to relevant mailing list
> > +   topics, related patch sets, or other notable discussion threads.
> > +   A convenient way to associate ``Link:`` trailers with the commit
> > +   message is to use markdown-like bracketed notation, for example::
> > ...
> > +     Link: https://lore.kernel.org/some-msgid@here # [1]
> > +     Link: https://bugzilla.example.org/bug/12345  # [2]
> 
> Why are we adding the extra "# " characters? The vast majority of
> existing Link tags don't do this:

That's just convention. In general, the hash separates the trailer from the
comment:

    Trailer-name: actual-trailer-body # comment

-K
Michael Ellerman June 22, 2024, 4:27 a.m. UTC | #4
Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:
> Based on multiple conversations, most recently on the ksummit mailing
> list [1], add some best practices for using the Link trailer, such as:
>
> - how to use markdown-like bracketed numbers in the commit message to
> indicate the corresponding link
> - when to use lore.kernel.org vs patch.msgid.link domains
>
> Cc: ksummit@lists.linux.dev
> Link: https://lore.kernel.org/20240617-arboreal-industrious-hedgehog-5b84ae@meerkat # [1]
> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
> ---
>  Documentation/process/maintainer-tip.rst | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/process/maintainer-tip.rst b/Documentation/process/maintainer-tip.rst
> index 64739968afa6..ba312345d030 100644
> --- a/Documentation/process/maintainer-tip.rst
> +++ b/Documentation/process/maintainer-tip.rst
> @@ -372,17 +372,31 @@ following tag ordering scheme:
>  
>   - Link: ``https://link/to/information``
>  
> -   For referring to an email on LKML or other kernel mailing lists,
> -   please use the lore.kernel.org redirector URL::
> +   For referring to an email posted to the kernel mailing lists, please
> +   use the lore.kernel.org redirector URL::
>  
> -     https://lore.kernel.org/r/email-message@id
> +     Link: https://lore.kernel.org/email-message-id@here
>  
> -   The kernel.org redirector is considered a stable URL, unlike other email
> -   archives.
> +   This URL should be used when referring to relevant mailing list
> +   topics, related patch sets, or other notable discussion threads.
> +   A convenient way to associate ``Link:`` trailers with the commit
> +   message is to use markdown-like bracketed notation, for example::
>  
> -   Maintainers will add a Link tag referencing the email of the patch
> -   submission when they apply a patch to the tip tree. This tag is useful
> -   for later reference and is also used for commit notifications.
> +     A similar approach was attempted before as part of a different
> +     effort [1], but the initial implementation caused too many
> +     regressions [2], so it was backed out and reimplemented.
> +
> +     Link: https://lore.kernel.org/some-msgid@here # [1]
> +     Link: https://bugzilla.example.org/bug/12345  # [2]

Does it actually make sense to use the Link: prefix here? These sort of
links are part of the prose, they're not something a script can download
and make any sense of.

I see some existing usage of the above style, but equally there's lots
of examples of footnote-style links without the Link: tag, eg:

commit 40b561e501768ef24673d0e1d731a7b9b1bc6709
Merge: d9f843fbd45e 31611cc8faa0
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Apr 29 22:29:44 2024 +0200

    Merge tag 'tee-ts-for-v6.10' of https://git.linaro.org/people/jens.wiklander/linux-tee into soc/drivers

    TEE driver for Trusted Services

    This introduces a TEE driver for Trusted Services [1].

    Trusted Services is a TrustedFirmware.org project that provides a
    framework for developing and deploying device Root of Trust services in
    FF-A [2] Secure Partitions. The project hosts the reference
    implementation of Arm Platform Security Architecture [3] for Arm
    A-profile devices.

    ...

    [1] https://www.trustedfirmware.org/projects/trusted-services/
    [2] https://developer.arm.com/documentation/den0077/
    [3] https://www.arm.com/architecture/security-features/platform-security


The above style is standard markdown style for reference links (or as
standard as markdown gets).

cheers
Kees Cook June 22, 2024, 2:40 p.m. UTC | #5
On June 21, 2024 9:27:34 PM PDT, Michael Ellerman <mpe@ellerman.id.au> wrote:
>Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:
>> Based on multiple conversations, most recently on the ksummit mailing
>> list [1], add some best practices for using the Link trailer, such as:
>>
>> - how to use markdown-like bracketed numbers in the commit message to
>> indicate the corresponding link
>> - when to use lore.kernel.org vs patch.msgid.link domains
>>
>> Cc: ksummit@lists.linux.dev
>> Link: https://lore.kernel.org/20240617-arboreal-industrious-hedgehog-5b84ae@meerkat # [1]
>> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
>> ---
>>  Documentation/process/maintainer-tip.rst | 30 ++++++++++++++++++++++--------
>>  1 file changed, 22 insertions(+), 8 deletions(-)
>>
>> diff --git a/Documentation/process/maintainer-tip.rst b/Documentation/process/maintainer-tip.rst
>> index 64739968afa6..ba312345d030 100644
>> --- a/Documentation/process/maintainer-tip.rst
>> +++ b/Documentation/process/maintainer-tip.rst
>> @@ -372,17 +372,31 @@ following tag ordering scheme:
>>  
>>   - Link: ``https://link/to/information``
>>  
>> -   For referring to an email on LKML or other kernel mailing lists,
>> -   please use the lore.kernel.org redirector URL::
>> +   For referring to an email posted to the kernel mailing lists, please
>> +   use the lore.kernel.org redirector URL::
>>  
>> -     https://lore.kernel.org/r/email-message@id
>> +     Link: https://lore.kernel.org/email-message-id@here
>>  
>> -   The kernel.org redirector is considered a stable URL, unlike other email
>> -   archives.
>> +   This URL should be used when referring to relevant mailing list
>> +   topics, related patch sets, or other notable discussion threads.
>> +   A convenient way to associate ``Link:`` trailers with the commit
>> +   message is to use markdown-like bracketed notation, for example::
>>  
>> -   Maintainers will add a Link tag referencing the email of the patch
>> -   submission when they apply a patch to the tip tree. This tag is useful
>> -   for later reference and is also used for commit notifications.
>> +     A similar approach was attempted before as part of a different
>> +     effort [1], but the initial implementation caused too many
>> +     regressions [2], so it was backed out and reimplemented.
>> +
>> +     Link: https://lore.kernel.org/some-msgid@here # [1]
>> +     Link: https://bugzilla.example.org/bug/12345  # [2]
>
>Does it actually make sense to use the Link: prefix here? These sort of
>links are part of the prose, they're not something a script can download
>and make any sense of.
>
>I see some existing usage of the above style, but equally there's lots
>of examples of footnote-style links without the Link: tag, eg:

I moved from that to using Link: because checkpatch would complain about my long (URL) lines unless it had a Link tag :P

>commit 40b561e501768ef24673d0e1d731a7b9b1bc6709
>Merge: d9f843fbd45e 31611cc8faa0
>Author: Arnd Bergmann <arnd@arndb.de>
>Date:   Mon Apr 29 22:29:44 2024 +0200
>
>    Merge tag 'tee-ts-for-v6.10' of https://git.linaro.org/people/jens.wiklander/linux-tee into soc/drivers
>
>    TEE driver for Trusted Services
>
>    This introduces a TEE driver for Trusted Services [1].
>
>    Trusted Services is a TrustedFirmware.org project that provides a
>    framework for developing and deploying device Root of Trust services in
>    FF-A [2] Secure Partitions. The project hosts the reference
>    implementation of Arm Platform Security Architecture [3] for Arm
>    A-profile devices.
>
>    ...
>
>    [1] https://www.trustedfirmware.org/projects/trusted-services/
>    [2] https://developer.arm.com/documentation/den0077/
>    [3] https://www.arm.com/architecture/security-features/platform-security
>
>
>The above style is standard markdown style for reference links (or as
>standard as markdown gets).

It's a good point. If we're formalizing this, why not literally use markdown instead? (I guess the answer is that out-of-line links/footnotes isn't standardized.)

Playing devil's advocate, outside of the kernel, these are the two most common styles I've seen:

Foo[1]
...
[1]: https://....

and

Bar[^1]
...
[^1] https://...

Personally, I only want to have a single official way to do this, and don't care much what it is. I have a minor preference for what you've described:

Baz[1]
...
[1] https://...

-Kees
Randy Dunlap June 22, 2024, 3:15 p.m. UTC | #6
On 6/22/24 7:40 AM, Kees Cook wrote:
>> I see some existing usage of the above style, but equally there's lots
>> of examples of footnote-style links without the Link: tag, eg:
> I moved from that to using Link: because checkpatch would complain about my long (URL) lines unless it had a Link tag :P

We know that checkpatch isn't perfect. It's safe to ignore such complaints.
Jonathan Corbet June 26, 2024, 11:13 p.m. UTC | #7
Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:

> On Fri, Jun 21, 2024 at 02:07:44PM GMT, Kees Cook wrote:
>> On Wed, Jun 19, 2024 at 02:24:07PM -0400, Konstantin Ryabitsev wrote:
>> > +   This URL should be used when referring to relevant mailing list
>> > +   topics, related patch sets, or other notable discussion threads.
>> > +   A convenient way to associate ``Link:`` trailers with the commit
>> > +   message is to use markdown-like bracketed notation, for example::
>> > ...
>> > +     Link: https://lore.kernel.org/some-msgid@here # [1]
>> > +     Link: https://bugzilla.example.org/bug/12345  # [2]
>> 
>> Why are we adding the extra "# " characters? The vast majority of
>> existing Link tags don't do this:
>
> That's just convention. In general, the hash separates the trailer from the
> comment:
>
>     Trailer-name: actual-trailer-body # comment
>

Did we ever come to a conclusion on this?  This one character seems to
be the main source of disagreement in this series, I'm wondering if I
should just apply it and let the painting continue thereafter...?

jon
Randy Dunlap June 26, 2024, 11:17 p.m. UTC | #8
On 6/26/24 4:13 PM, Jonathan Corbet wrote:
> Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:
> 
>> On Fri, Jun 21, 2024 at 02:07:44PM GMT, Kees Cook wrote:
>>> On Wed, Jun 19, 2024 at 02:24:07PM -0400, Konstantin Ryabitsev wrote:
>>>> +   This URL should be used when referring to relevant mailing list
>>>> +   topics, related patch sets, or other notable discussion threads.
>>>> +   A convenient way to associate ``Link:`` trailers with the commit
>>>> +   message is to use markdown-like bracketed notation, for example::
>>>> ...
>>>> +     Link: https://lore.kernel.org/some-msgid@here # [1]
>>>> +     Link: https://bugzilla.example.org/bug/12345  # [2]
>>>
>>> Why are we adding the extra "# " characters? The vast majority of
>>> existing Link tags don't do this:
>>
>> That's just convention. In general, the hash separates the trailer from the
>> comment:
>>
>>     Trailer-name: actual-trailer-body # comment
>>
> 
> Did we ever come to a conclusion on this?  This one character seems to
> be the main source of disagreement in this series, I'm wondering if I
> should just apply it and let the painting continue thereafter...?

We have used '#' for ages for adding comments to by: tags.
I'm surprised that it's not documented.
diff mbox series

Patch

diff --git a/Documentation/process/maintainer-tip.rst b/Documentation/process/maintainer-tip.rst
index 64739968afa6..ba312345d030 100644
--- a/Documentation/process/maintainer-tip.rst
+++ b/Documentation/process/maintainer-tip.rst
@@ -372,17 +372,31 @@  following tag ordering scheme:
 
  - Link: ``https://link/to/information``
 
-   For referring to an email on LKML or other kernel mailing lists,
-   please use the lore.kernel.org redirector URL::
+   For referring to an email posted to the kernel mailing lists, please
+   use the lore.kernel.org redirector URL::
 
-     https://lore.kernel.org/r/email-message@id
+     Link: https://lore.kernel.org/email-message-id@here
 
-   The kernel.org redirector is considered a stable URL, unlike other email
-   archives.
+   This URL should be used when referring to relevant mailing list
+   topics, related patch sets, or other notable discussion threads.
+   A convenient way to associate ``Link:`` trailers with the commit
+   message is to use markdown-like bracketed notation, for example::
 
-   Maintainers will add a Link tag referencing the email of the patch
-   submission when they apply a patch to the tip tree. This tag is useful
-   for later reference and is also used for commit notifications.
+     A similar approach was attempted before as part of a different
+     effort [1], but the initial implementation caused too many
+     regressions [2], so it was backed out and reimplemented.
+
+     Link: https://lore.kernel.org/some-msgid@here # [1]
+     Link: https://bugzilla.example.org/bug/12345  # [2]
+
+   You can also use ``Link:`` trailers to indicate the origin of the
+   patch when applying it to your git tree. In that case, please use the
+   dedicated ``patch.msgid.link`` domain instead of ``lore.kernel.org``.
+   This practice makes it possible for automated tooling to identify
+   which link to use to retrieve the original patch submission. For
+   example::
+
+     Link: https://patch.msgid.link/patch-source-message-id@here
 
 Please do not use combined tags, e.g. ``Reported-and-tested-by``, as
 they just complicate automated extraction of tags.