git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 16:50 UTC

Re: [PATCH 3/3] format-patch: learn --[no-]range-diff-notes

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2026, 17:12 UTC
Message-ID
<xmqqcxuq483g.fsf@gitster.g>
In-Reply-To
<e3b7ef75-08e6-4529-ac75-56f800d2f4a4@app.fastmail.com>
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
Show 17 quoted lines
> Seeing as how the doc was unclear and did not spell out how you can
> build two separate list of notes, here’s a draft of a rewrite:
>
>     `--range-diff-notes[=<ref>]`::
>     `--no-range-diff-notes`::
>             Used with `--range-diff`, tweak what notes to display in the
>             range diff.
>     +
>     The default behavior is to display the same notes in the range diff as
>     on the patches; see `--notes`. But you can use these options to use a
>     different list of notes. For example, say you have given three notes
>     refs to `--notes`. At this point those same three notes will be
>     displayed in the range diff. But then you pass
>     `--range-diff-notes=<ref>`. Now the range diff will only display
>     _<ref>_. You can of course pass more refs to this option, just like
>     `--notes`. And you can also turn off all notes with
>     `--no-range-diff-notes`.

Up to this point it is quite clear how the two interact. Even though it does not appear in the above paragraph, the rules essentially are "Without --range-diff-notes, the refs that are specified by --notes are used for both purposes" and "When you use --range-diff-notes, --notes and --range-diff-notes give independent sets of notes, the former is shown only in the output, the latter is used only for comparison".

But the following paragraph, while it may be correctly describing what the code does, does not tell me why you would even want to do so.

For example, if you have --notes=foo --notes=bar always given in an alias, i.e.

    [alias] fmt = format-patch --notes=foo --notes=bar

but in one invocation you would want to use different set of notes only for comparison, you would

    git fmt --range-diff-notes=
if you do not want any notes participate in the comparison, or
    git fmt --range-diff-notes=bar
you want only 'bar' to be used in the comparison.
If you had --range-diff-notes=foo in a similar way in an alias,
    [alias] fmtr = format-patch --range-diff-notes=foo --notes=bar

you may need a way to tell that 'foo' no longer participates in the comparison with

    git fmtr --no-range-diff-notes

If the rule is that once you say --no-range-diff-notes the internal state is reset and the command behaves as if no --range-diff-notes option is ever given [*], then that would still leave --notes=bar so the command would beave as if

    git format-patch --notes=bar

were given, which means bar will now affect both, so if you want 'bar' not to be used for comparison, you would need some way to pretend as if you said

    git format-patch --range-diff-notes= --notes=bar
and ...
Show 11 quoted lines
>     +
>     You may want to turn off this notes override behavior after it has been
>     activated. Use this sequence to do that:
>     +
>     ----
>     --no-range-diff-notes --range-diff-notes
>     ----
>     +
>     Now the range diff is back to displaying the same notes as the
>     patches. Going back to the three `--notes` example: now the range diff
>     will show all three notes again.
... may be a way to do so, perhaps?

BUT I think that is a strange interpretation and notation. Normal people would rather assume, once you said --no-range-diff-notes, you do not want any notes to be used for range-diff comparison. IOW, I find the earlier rule [*] that makes --no-range-diff-notes only tell the command to pretend that no --range-diff-notes is ever given, which leads to the above conclusion, a source of confusion.

If the rule were "if you say --no-range-diff-notes, you are saying that you do not want any notes used for range-diff" (and similarly "if you say --no-notes you are saying that you do not want any notes used"), would it make the workaround in the last part unnecessary? Under such a world order,

    git fmtr --no-range-diff-notes

would mean that --no-range-diff-notes tells that you do not want any notes participate in the comparison, so any --notes in the alias definition of fmtr would be used only for the final display. And

    git fmtr --no-range-diff-notes --range-diff-notes

would tell the command that on top of the previous state, you are adding 0 notes to the set of notes used for comparisons, so it would be a no op. If it were

    git fmtr --no-range-diff-notes --range-diff-notes=bar

then you'd let --notes in the fmtr alias definition to be used for final display, --range-diff-notes in the fmtr alias definition to be totally ignored, and bar is used for comparison.

Would that logically make sense and make it easier to understand?
Thanks.
Previous: Kristoffer HaugsbakkNext: D. Ben Knoble
Message 14 of 41 in “format-patch: learn --[no-]range-diff-notes”
  1. 0/3 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Aug 24, 2026
  2. 1/3 format-patch: simplify get_notes_arg parameterskristofferhaugsbakk@fastmail.com, Aug 24, 2026
  3. 2/3 revision.h: rename struct member to reflect notes rolekristofferhaugsbakk@fastmail.com, Aug 24, 2026
  4. 3/3 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Aug 24, 2026
  5. Junio C HamanoAug 24, 2026
  6. Kristoffer HaugsbakkAug 25, 2026
  7. Junio C HamanoAug 28, 2026
  8. Kristoffer HaugsbakkAug 28, 2026
  9. Junio C HamanoAug 28, 2026
  10. Kristoffer HaugsbakkSep 2, 2026
  11. Kristoffer HaugsbakkSep 6, 2026
  12. D. Ben KnobleSep 6, 2026
  13. Kristoffer HaugsbakkSep 6, 2026
  14. Junio C HamanoSep 6, 2026
  15. D. Ben KnobleSep 6, 2026
  16. Kristoffer HaugsbakkSep 9, 2026
  17. Junio C HamanoSep 9, 2026
  18. 0/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Sep 26, 2026
  19. 1/2 format-patch: simplify get_notes_arg parameterskristofferhaugsbakk@fastmail.com, Sep 26, 2026
  20. 2/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Sep 26, 2026
  21. Junio C HamanoSep 27, 2026
  22. Kristoffer HaugsbakkSep 27, 2026
  23. Junio C HamanoSep 28, 2026
  24. Kristoffer HaugsbakkSep 28, 2026
  25. 0/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Oct 2, 2026
  26. 1/2 format-patch: simplify get_notes_arg parameterskristofferhaugsbakk@fastmail.com, Oct 2, 2026
  27. 2/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Oct 2, 2026
  28. Junio C HamanoOct 2, 2026
  29. Junio C HamanoOct 2, 2026
  30. Kristoffer HaugsbakkOct 2, 2026
  31. Kristoffer HaugsbakkOct 2, 2026
  32. Kristoffer HaugsbakkOct 2, 2026
  33. Kristoffer HaugsbakkOct 2, 2026
  34. 0/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Oct 4, 2026
  35. 1/2 format-patch: simplify get_notes_arg parameterskristofferhaugsbakk@fastmail.com, Oct 4, 2026
  36. 2/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Oct 4, 2026
  37. Junio C HamanoOct 4, 2026
  38. Kristoffer HaugsbakkOct 4, 2026
  39. 0/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Oct 4, 2026
  40. 1/2 format-patch: simplify get_notes_arg parameterskristofferhaugsbakk@fastmail.com, Oct 4, 2026
  41. 2/2 format-patch: learn --[no-]range-diff-noteskristofferhaugsbakk@fastmail.com, Oct 4, 2026

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.