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

Re: [PATCH 1/2] revision: add rdiff_other_arg to rev_info

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2025, 21:58 UTC
Message-ID
<xmqqikharvyl.fsf@gitster.g>
In-Reply-To
<bb065767336.1758574974.git.code@khaugsbakk.name>
kristofferhaugsbakk@fastmail.com writes:
> git-format-patch(1) is supposed to treat Git notes the same between
> notes output beneath the commit message and the notes output for the
> range-diff.

Is this an opinion, or are there things that existing pieces of code already do to achieve such a behaviour already?

Show 11 quoted lines
> diff --git a/revision.h b/revision.h
> index 21e288c5baa..26c18a0934b 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -334,6 +334,7 @@ struct rev_info {
>  	/* range-diff */
>  	const char *rdiff1;
>  	const char *rdiff2;
> +	struct strvec rdiff_other_arg;
>  	int creation_factor;
>  	const char *rdiff_title;

When embedding a struct A in a struct B, we should always make sure that initialization macro/function for struct B is updated so that the initialization for struct A is done correctly for the new member.

We do have REV_INFO_INIT for "struct rev_info"
        #define REV_INFO_INIT { \
                .abbrev = DEFAULT_ABBREV, \
                .simplify_history = 1, \
                .pruning.flags.recursive = 1, \
                ...
                .expand_tabs_in_log_default = 8, \
        }

that does not allow any existing callers to leave it uninitialized or get away by zero-initializing, so all the users must be using it or the system before your patch is already buggy.

And we do have STRVEC_INIT that we must use in that initializer.
        extern const char *empty_strvec[];
        struct strvec {
                const char **v;
                size_t nr;
                size_t alloc;
        };
        #define STRVEC_INIT { \
                .v = empty_strvec, \
        }

So this step forgets to update revision.h to teach STRVEC_INIT on the new rdiff_other_arg member.

Back when it was a random one-shot variable in range-diff, it might not have mattered all that much, but now we have it as a proper member of the struct, can we give it a name better than 'other_arg"? Or is it the case that truly any random crap can be slurped into the array and thrown back at "git log" without range-diff machinery understanding what it is doing at all (which I would not be surprised, as some parts of our code base is written in somewhat a sloppy way)?

Thanks.
Previous: kristofferhaugsbakk@fastmail.comNext: Kristoffer Haugsbakk
Message 3 of 15 in “format-patch: handle range-diff on notes correctly for single patches”
  1. 0/2 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 22, 2025
  2. 1/2 revision: add rdiff_other_arg to rev_infokristofferhaugsbakk@fastmail.com, Sep 22, 2025
  3. Junio C HamanoSep 22, 2025
  4. Kristoffer HaugsbakkSep 23, 2025
  5. Junio C HamanoSep 23, 2025
  6. Kristoffer HaugsbakkSep 23, 2025
  7. Junio C HamanoSep 23, 2025
  8. 2/2 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 22, 2025
  9. Junio C HamanoSep 22, 2025
  10. Kristoffer HaugsbakkSep 23, 2025
  11. Junio C HamanoSep 23, 2025
  12. 0/3 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 25, 2025
  13. 1/3 range-diff: rename other_arg to log_argkristofferhaugsbakk@fastmail.com, Sep 25, 2025
  14. 2/3 revision: add rdiff_log_arg to rev_infokristofferhaugsbakk@fastmail.com, Sep 25, 2025
  15. 3/3 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 25, 2025

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.