git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/5] trailer: add tests to check defaulting behavior with --no-* flags

From
LALinus Arver <linusa@google.com>
Date
Aug 7, 2023, 05:28 UTC
Message-ID
<owlyfs4vbeus.fsf@fine.c.googlers.com>
In-Reply-To
<xmqqjzu7irhw.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> "Linus Arver via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> @@ -114,8 +114,10 @@ OPTIONS
>>  	Specify where all new trailers will be added.  A setting
>>  	provided with '--where' overrides all configuration variables
>
> Obviously this is not a new issue, but "all configuration variables"
> is misleading (the same comment applies to the description of the
> "--[no-]if-exists" and the "--[no-]if-missing" options).
Agreed.
> If I am reading the code correctly, --where=value overrides the
> trailer.where variable and nothing else, and --no-where stops the
> overriding of the trailer.where variable.  Ditto for the other two
> with their relevant configuration variables.
That is also my understanding. Will update to remove the "all" wording.

On a separate note, I've realized there are more fixes to be done in this area (as I get more familiar with the codebase). For example, we have the following language in builtin/interpret-trailers.c inside cmd_interpret_trailers():

    OPT_BOOL(0, "only-input", &opts.only_input, N_("do not apply config rules")),

which should be fixed in similar style to what you suggested above, probably with:

    OPT_BOOL(0, "only-input", &opts.only_input, N_("do not apply trailer.* configuration variables")),

When I reroll, I will include these additional fixes so expect the patch series to grow (probably ~12 patches instead of the ~5).

One more thing. I think the documentation (Documentation/git-interpret-trailers.txt) uses the word "<token>" in two different ways. For example, if we have in the input

    subject line
    body text
    Acked-by: Foo

the docs treat the word "Acked-by:" as the <token>. However, it defines the relevant configuration section like this:

    trailer.<token>.key::
            This `key` will be used instead of <token> in the trailer. At
            the end of this key, a separator can appear and then some
            space characters. By default the only valid separator is ':',
            but this can be changed using the `trailer.separators` config
            variable.
    +
    If there is a separator, then the key will be used instead of both the
    <token> and the default separator when adding the trailer.
So if I configure this like
   git config trailer.ack.key "Acked-by" &&

the <token> is both the longer-form "Acked-by:" (per the meaning so far in the doc) but also the shorter string "ack" per the "trailer.<token>.key" configuration section syntax. This secondary meaning is repeated again in the very start of the doc when we define the --trailer option syntax as

    SYNOPSIS
    --------
    [verse]
    'git interpret-trailers' [--in-place] [--trim-empty]
                [(--trailer <token>[(=|:)<value>])...]
                [--parse] [<file>...]

because the <token> here could be (using the example above) either "Acked-by" (as in "--trailer=Acked-by:...") if we did not configure "trailer.ack.key", or just "ack" (as in "--trailer=ack:...") if we did configure it. These two scenarios would give identical "Acked-by: ..." output.

This is confusing and I don't like how we overload this "token" word (not to mention we already have the word "key" which we don't really use much in the docs).

I am inclined to replace most uses of the word "<token>" with "<key>" while leaving the "trailer.<token>.key" configuration syntax intact. This will result in a large diff but I think the removal of the double meaning is worth it, and will include this fix also in the next reroll.

The main reason I bring this up is because this means also having to update our funciton names like "token_len_without_separator" in trailer.c, to be "key_len_without_separator" if we want the nomenclature in the trailer.c internals to be consistent with the (updated) user-facing docs. I am not sure whether we want to do this as part of the same reroll, or if we should leave it as #leftoverbits for a future series.

Previous: Junio C HamanoNext: Linus Arver
Message 9 of 52 in “Fixes to trailer test script, help text, and documentation”
  1. 0/5 Fixes to trailer test script, help text, and documentationLinus Arver via GitGitGadget, Aug 5, 2023
  2. 2/5 trailer test description: this tests --where=after, not --where=beforeLinus Arver via GitGitGadget, Aug 5, 2023
  3. 5/5 trailer --no-divider help: describe usual "---" meaningLinus Arver via GitGitGadget, Aug 5, 2023
  4. 1/5 trailer tests: make test cases self-containedLinus Arver via GitGitGadget, Aug 5, 2023
  5. Linus ArverAug 7, 2023
  6. 4/5 trailer: trailer location is a place, not an actionLinus Arver via GitGitGadget, Aug 5, 2023
  7. 3/5 trailer: add tests to check defaulting behavior with --no-* flagsLinus Arver via GitGitGadget, Aug 5, 2023
  8. Junio C HamanoAug 7, 2023
  9. Linus ArverAug 7, 2023
  10. Linus ArverAug 7, 2023
  11. Linus ArverAug 7, 2023
  12. Junio C HamanoAug 7, 2023
  13. 00/13 Fixes to trailer test script, help text, and documentationLinus Arver via GitGitGadget, Aug 10, 2023
  14. 02/13 trailer test description: this tests --where=after, not --where=beforeLinus Arver via GitGitGadget, Aug 10, 2023
  15. 01/13 trailer tests: make test cases self-containedLinus Arver via GitGitGadget, Aug 10, 2023
  16. 04/13 trailer doc: narrow down scope of --where and related flagsLinus Arver via GitGitGadget, Aug 10, 2023
  17. 03/13 trailer: add tests to check defaulting behavior with --no-* flagsLinus Arver via GitGitGadget, Aug 10, 2023
  18. 05/13 trailer: trailer location is a place, not an actionLinus Arver via GitGitGadget, Aug 10, 2023
  19. 06/13 trailer --no-divider help: describe usual "---" meaningLinus Arver via GitGitGadget, Aug 10, 2023
  20. 07/13 trailer --parse help: expose aliased optionsLinus Arver via GitGitGadget, Aug 10, 2023
  21. 09/13 trailer --parse docs: add explanation for its usefulnessLinus Arver via GitGitGadget, Aug 10, 2023
  22. 10/13 trailer --unfold help: prefer "reformat" over "join"Linus Arver via GitGitGadget, Aug 10, 2023
  23. 08/13 trailer --only-input: prefer "configuration variables" over "rules"Linus Arver via GitGitGadget, Aug 10, 2023
  24. 11/13 trailer doc: emphasize the effect of configuration variablesLinus Arver via GitGitGadget, Aug 10, 2023
  25. 12/13 trailer doc: separator within key suppresses default separatorLinus Arver via GitGitGadget, Aug 10, 2023
  26. 13/13 trailer doc: <token> is a <key> or <keyAlias>, not bothLinus Arver via GitGitGadget, Aug 10, 2023
  27. Junio C HamanoAug 11, 2023
  28. Linus ArverAug 11, 2023
  29. 00/13 Fixes to trailer test script, help text, and documentationLinus Arver via GitGitGadget, Sep 7, 2023
  30. 02/13 trailer test description: this tests --where=after, not --where=beforeLinus Arver via GitGitGadget, Sep 7, 2023
  31. 03/13 trailer: add tests to check defaulting behavior with --no-* flagsLinus Arver via GitGitGadget, Sep 7, 2023
  32. Junio C HamanoSep 8, 2023
  33. 01/13 trailer tests: make test cases self-containedLinus Arver via GitGitGadget, Sep 7, 2023
  34. 04/13 trailer doc: narrow down scope of --where and related flagsLinus Arver via GitGitGadget, Sep 7, 2023
  35. 06/13 trailer --no-divider help: describe usual "---" meaningLinus Arver via GitGitGadget, Sep 7, 2023
  36. Junio C HamanoSep 8, 2023
  37. 05/13 trailer: trailer location is a place, not an actionLinus Arver via GitGitGadget, Sep 7, 2023
  38. Jonathan TanSep 19, 2023
  39. 08/13 trailer --only-input: prefer "configuration variables" over "rules"Linus Arver via GitGitGadget, Sep 7, 2023
  40. 10/13 trailer --unfold help: prefer "reformat" over "join"Linus Arver via GitGitGadget, Sep 7, 2023
  41. 09/13 trailer --parse docs: add explanation for its usefulnessLinus Arver via GitGitGadget, Sep 7, 2023
  42. Junio C HamanoSep 8, 2023
  43. 07/13 trailer --parse help: expose aliased optionsLinus Arver via GitGitGadget, Sep 7, 2023
  44. Jonathan TanSep 19, 2023
  45. 12/13 trailer doc: separator within key suppresses default separatorLinus Arver via GitGitGadget, Sep 7, 2023
  46. 11/13 trailer doc: emphasize the effect of configuration variablesLinus Arver via GitGitGadget, Sep 7, 2023
  47. 13/13 trailer doc: <token> is a <key> or <keyAlias>, not bothLinus Arver via GitGitGadget, Sep 7, 2023
  48. Jonathan TanSep 19, 2023
  49. Linus ArverSep 20, 2023
  50. Junio C HamanoSep 20, 2023
  51. Linus ArverSep 22, 2023
  52. 13/13 trailer doc: <token> is a <key> or <keyAlias>, not bothTeng Long, Nov 10, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.