From bfb5f57bb33c864c162c13667b2d02b573a179f3 Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:42 +0000 Subject: [PATCH 1/9] doc: trailer: fix grammar Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 4b97f812be..35faf83789 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Help parsing or adding 'trailers' lines, that look similar to RFC 822 e-mail +Parse or add 'trailer' lines that look similar to RFC 822 e-mail headers, at the end of the otherwise free-form part of a commit message. @@ -249,10 +249,10 @@ for the same , 'trailer..cmd' is used and 'trailer..command' is ignored. trailer..cmd:: - This option can be used to specify a shell command that will be called: + This option can be used to specify a shell command that will be called once to automatically add a trailer with the specified , and then - each time a '--trailer =' argument to modify the of - the trailer that this option would produce. + called each time a '--trailer =' argument is specified to + modify the of the trailer that this option would produce. + When the specified command is first called to add a trailer with the specified , the behavior is as if a special From 00432a36e20f86338774e5daf8c7fb2eff0beda8 Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:43 +0000 Subject: [PATCH 2/9] doc: trailer: swap verb order This matches the order already used in the NAME section. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 35faf83789..da8fec7d5f 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Parse or add 'trailer' lines that look similar to RFC 822 e-mail +Add or parse 'trailer' lines that look similar to RFC 822 e-mail headers, at the end of the otherwise free-form part of a commit message. From 94f15fe5d5d2c119908e3f95c69a86cb9e905439 Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:44 +0000 Subject: [PATCH 3/9] doc: trailer: drop "commit message part" phrasing The command can take inputs that are either just a commit message, or an email-like output such as git-format-patch which includes a commit message, "---" divider, and patch part. The existing explanation blends these two inputs together in the first sentence This command reads some patches or commit messages which then necessitates using the "commit message part" phrasing (as opposed to just "commit message") because the input is ambiguous per the above definition. This change separates the two input types and explains them separately, and so there is no longer a need to use the "commit message part" phrase. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 36 +++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index da8fec7d5f..d0a0b30388 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -18,17 +18,23 @@ Add or parse 'trailer' lines that look similar to RFC 822 e-mail headers, at the end of the otherwise free-form part of a commit message. -This command reads some patches or commit messages from either the - arguments or the standard input if no is specified. If -`--parse` is specified, the output consists of the parsed trailers. - +This command reads commit messages from either the + arguments or the standard input if no is specified. +If `--parse` is specified, the output consists of the parsed trailers. Otherwise, this command applies the arguments passed using the -`--trailer` option, if any, to the commit message part of each input -file. The result is emitted on the standard output. +`--trailer` option, if any, to each input file. The result is emitted on the +standard output. + +This command can also operate on the output of linkgit:git-format-patch[1], +which is more elaborate than a plain commit message. Namely, such output +includes a commit message (as above), a "---" divider line, and a patch part. +For these inputs, the divider and patch parts are not modified by +this command and are emitted as is on the output, unless +`--no-divider` is specified. Some configuration variables control the way the `--trailer` arguments -are applied to each commit message and the way any existing trailer in -the commit message is changed. They also make it possible to +are applied to each input and the way any existing trailer in +the input is changed. They also make it possible to automatically add some trailers. By default, a '=' or ':' argument given @@ -36,7 +42,7 @@ using `--trailer` will be appended after the existing trailers only if the last trailer has a different (, ) pair (or if there is no existing trailer). The and parts will be trimmed to remove starting and trailing whitespace, and the resulting trimmed - and will appear in the message like this: + and will appear in the output like this: ------------------------------------------------ token: value @@ -47,19 +53,17 @@ This means that the trimmed and will be separated by By default the new trailer will appear at the end of all the existing trailers. If there is no existing trailer, the new trailer will appear -after the commit message part of the output, and, if there is no line -with only spaces at the end of the commit message part, one blank line -will be added before the new trailer. +at the end of the input. A blank line will be added before the new +trailer if there isn't one already. -Existing trailers are extracted from the input message by looking for +Existing trailers are extracted from the input by looking for a group of one or more lines that (i) is all trailers, or (ii) contains at least one Git-generated or user-configured trailer and consists of at least 25% trailers. The group must be preceded by one or more empty (or whitespace-only) lines. -The group must either be at the end of the message or be the last +The group must either be at the end of the input or be the last non-whitespace lines before a line that starts with '---' (followed by a -space or the end of the line). Such three minus signs start the patch -part of the message. See also `--no-divider` below. +space or the end of the line). When reading trailers, there can be no whitespace before or inside the token, but any number of regular space and tab characters are allowed From 229d6ab6bf1976906c1f0294c3f1781c12478505 Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:45 +0000 Subject: [PATCH 4/9] doc: trailer: examples: avoid the word "message" by itself Previously, "message" could mean the input, output, commit message, or "internal body text inside the commit message" (in the EXAMPLES section). Avoid overloading this term by using the appropriate meanings explicitly. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index d0a0b30388..58a9c69149 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -83,12 +83,12 @@ OPTIONS --trim-empty:: If the part of any trailer contains only whitespace, - the whole trailer will be removed from the resulting message. + the whole trailer will be removed from the output. This applies to existing trailers as well as new trailers. --trailer [(=|:)]:: Specify a (, ) pair that should be applied as a - trailer to the input messages. See the description of this + trailer to the inputs. See the description of this command. --where :: @@ -102,7 +102,7 @@ OPTIONS --if-exists :: --no-if-exists:: Specify what action will be performed when there is already at - least one trailer with the same in the message. A setting + least one trailer with the same in the input. A setting provided with '--if-exists' overrides all configuration variables and applies to all '--trailer' options until the next occurrence of '--if-exists' or '--no-if-exists'. Possible actions are `addIfDifferent`, @@ -111,7 +111,7 @@ OPTIONS --if-missing :: --no-if-missing:: Specify what action will be performed when there is no other - trailer with the same in the message. A setting + trailer with the same in the input. A setting provided with '--if-missing' overrides all configuration variables and applies to all '--trailer' options until the next occurrence of '--if-missing' or '--no-if-missing'. Possible actions are `doNothing` @@ -178,7 +178,7 @@ first trailer with the same . trailer.ifexists:: This option makes it possible to choose what action will be performed when there is already at least one trailer with the - same in the message. + same in the input. + The valid values for this option are: `addIfDifferentNeighbor` (this is the default), `addIfDifferent`, `add`, `replace` or `doNothing`. @@ -188,10 +188,10 @@ trailer with the same (, ) pair is above or below the line where the new trailer will be added. + With `addIfDifferent`, a new trailer will be added only if no trailer -with the same (, ) pair is already in the message. +with the same (, ) pair is already in the input. + With `add`, a new trailer will be added, even if some trailers with -the same (, ) pair are already in the message. +the same (, ) pair are already in the input. + With `replace`, an existing trailer with the same will be deleted and the new trailer will be added. The deleted trailer will be @@ -199,12 +199,12 @@ the closest one (with the same ) to the place where the new one will be added. + With `doNothing`, nothing will be done; that is no new trailer will be -added if there is already one with the same in the message. +added if there is already one with the same in the input. trailer.ifmissing:: This option makes it possible to choose what action will be performed when there is not yet any trailer with the same - in the message. + in the input. + The valid values for this option are: `add` (this is the default) and `doNothing`. @@ -276,37 +276,37 @@ EXAMPLES -------- * Configure a 'sign' trailer with a 'Signed-off-by' key, and then - add two of these trailers to a message: + add two of these trailers to a commit message file: + ------------ $ git config trailer.sign.key "Signed-off-by" $ cat msg.txt subject -message +body text $ git interpret-trailers --trailer 'sign: Alice ' --trailer 'sign: Bob ' Signed-off-by: Bob ------------ -* Use the `--in-place` option to edit a message file in place: +* Use the `--in-place` option to edit a commit message file in place: + ------------ $ cat msg.txt subject -message +body text Signed-off-by: Bob $ git interpret-trailers --trailer 'Acked-by: Alice ' --in-place msg.txt $ cat msg.txt subject -message +body text Signed-off-by: Bob Acked-by: Alice @@ -329,7 +329,7 @@ $ git interpret-trailers --trailer 'Cc: Alice ' --trailer 'Re $ cat msg1.txt subject -message +body text $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing @@ -337,19 +337,19 @@ $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user. $ git interpret-trailers --trailer sign $ cat msg2.txt subject -message +body text Signed-off-by: Alice $ git interpret-trailers --trailer sign ------------ @@ -377,14 +377,14 @@ test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true $ cat msg.txt subject -message +body text $ git config trailer.help.key "Helped-by: " $ git config trailer.help.ifExists "addIfDifferentNeighbor" $ git config trailer.help.cmd "~/bin/glog-find-author" $ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" Helped-by: Christian Couder @@ -401,14 +401,14 @@ test -n "$1" && git log --grep "$1" --pretty=reference -1 || true $ cat msg.txt subject -message +body text $ git config trailer.ref.key "Reference-to: " $ git config trailer.ref.ifExists "replace" $ git config trailer.ref.cmd "~/bin/glog-grep" $ git interpret-trailers --trailer="ref:Add copyright notices." Date: Thu, 15 Jun 2023 02:53:46 +0000 Subject: [PATCH 5/9] doc: trailer: remove redundant phrasing The phrase "many rules" gets essentially repeated again with "many other rules", so remove this repetition. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 58a9c69149..7516593c47 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -72,9 +72,8 @@ inside or after the value. The value may be split over multiple lines with each subsequent line starting with at least one whitespace, like the "folding" in RFC 822. -Note that 'trailers' do not follow and are not intended to follow many -rules for RFC 822 headers. For example they do not follow -the encoding rules and probably many other rules. +Note that trailers do not follow (nor are they intended to follow) many of the +rules for RFC 822 headers. For example they do not follow the encoding rule. OPTIONS ------- From 8e80f2916b82501b9d726b75ba0df32c951e4a7e Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:47 +0000 Subject: [PATCH 6/9] doc: trailer: use angle brackets for and We already use angle brackets elsewhere, so this makes things more consistent. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 7516593c47..97dc1c8c95 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -66,9 +66,9 @@ non-whitespace lines before a line that starts with '---' (followed by a space or the end of the line). When reading trailers, there can be no whitespace before or inside the -token, but any number of regular space and tab characters are allowed -between the token and the separator. There can be whitespaces before, -inside or after the value. The value may be split over multiple lines +, but any number of regular space and tab characters are allowed +between the and the separator. There can be whitespaces before, +inside or after the . The may be split over multiple lines with each subsequent line starting with at least one whitespace, like the "folding" in RFC 822. @@ -241,7 +241,7 @@ trailer..command:: This option behaves in the same way as 'trailer..cmd', except that it doesn't pass anything as argument to the specified command. Instead the first occurrence of substring $ARG is replaced by the - value that would be passed as argument. + that would be passed as argument. + The 'trailer..command' option has been deprecated in favor of 'trailer..cmd' due to the fact that $ARG in the user's command is From dc8937fbb99aa00de777852cc7d04d0534bb956c Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:48 +0000 Subject: [PATCH 7/9] doc: trailer..command: emphasize deprecation This puts the deprecation notice up front, instead of leaving it to the next paragraph. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 97dc1c8c95..6016af5c20 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -238,13 +238,13 @@ trailer..ifmissing:: that option for trailers with the specified . trailer..command:: + Deprecated in favor of 'trailer..cmd'. This option behaves in the same way as 'trailer..cmd', except that it doesn't pass anything as argument to the specified command. Instead the first occurrence of substring $ARG is replaced by the that would be passed as argument. + -The 'trailer..command' option has been deprecated in favor of -'trailer..cmd' due to the fact that $ARG in the user's command is +Note that $ARG in the user's command is only replaced once and that the original way of replacing $ARG is not safe. + When both 'trailer..cmd' and 'trailer..command' are given From eda2c44c8b999547c0726baa7a12a40960ac5d6a Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:49 +0000 Subject: [PATCH 8/9] doc: trailer: mention 'key' in DESCRIPTION The 'key' option is used frequently in the examples at the bottom but there is no mention of it in the description. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 6016af5c20..7e77cbb1ca 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -49,7 +49,10 @@ token: value ------------------------------------------------ This means that the trimmed and will be separated by -`': '` (one colon followed by one space). +`': '` (one colon followed by one space). For convenience, the can be a +shortened string key (e.g., "sign") instead of the full string which should +appear before the separator on the output (e.g., "Signed-off-by"). This can be +configured using the 'trailer..key' configuration variable. By default the new trailer will appear at the end of all the existing trailers. If there is no existing trailer, the new trailer will appear From d57fa7fc73202af226b6c0e0d9788c6460ce23b9 Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Thu, 15 Jun 2023 02:53:50 +0000 Subject: [PATCH 9/9] doc: trailer: add more examples in DESCRIPTION Be more up-front about what trailers are in practice with examples, to give the reader a visual cue while they go on to read the rest of the description. Also add an example for multiline values. Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- Documentation/git-interpret-trailers.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 7e77cbb1ca..55d8961466 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -16,7 +16,18 @@ DESCRIPTION ----------- Add or parse 'trailer' lines that look similar to RFC 822 e-mail headers, at the end of the otherwise free-form part of a commit -message. +message. For example, in the following commit message + +------------------------------------------------ +subject + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +Signed-off-by: Alice +Signed-off-by: Bob +------------------------------------------------ + +the last two lines starting with "Signed-off-by" are trailers. This command reads commit messages from either the arguments or the standard input if no is specified. @@ -73,7 +84,12 @@ When reading trailers, there can be no whitespace before or inside the between the and the separator. There can be whitespaces before, inside or after the . The may be split over multiple lines with each subsequent line starting with at least one whitespace, like -the "folding" in RFC 822. +the "folding" in RFC 822. Example: + +------------------------------------------------ +token: This is a very long value, with spaces and + newlines in it. +------------------------------------------------ Note that trailers do not follow (nor are they intended to follow) many of the rules for RFC 822 headers. For example they do not follow the encoding rule.