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

Re: [PATCH 2/2] notes: break set_display_notes() into smaller functions

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 18, 2019, 16:18 UTC
Message-ID
<CAPig+cRVyfWceVZFgRuRyL-B3TMnX9fObC84t2LHsNoXm8TuqQ@mail.gmail.com>
In-Reply-To
<96b908c91c19bc11da9f8d3b0d6e853517284540.1576111643.git.liu.denton@gmail.com>
On Wed, Dec 11, 2019 at 7:48 PM Denton Liu <liu.denton@gmail.com> wrote:
Show 15 quoted lines
> In 8164c961e1 (format-patch: use --notes behavior for format.notes,
> 2019-12-09), we introduced set_display_notes() which was a monolithic
> function with three mutually exclusive branches. Break the function up
> into three small and simple functions that each are only responsible for
> one task.
> [...]
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
> diff --git a/notes.c b/notes.c
> @@ -1045,28 +1045,31 @@ void init_display_notes(struct display_notes_opt *opt)
> +void disable_display_notes(struct display_notes_opt *opt, int *show_notes)
> +{
> +       opt->use_default_notes = -1;
> +       /* we have been strdup'ing ourselves, so trick
> +        * string_list into free()ing strings */
    /*
     * Multi-line comment
     * style.
     */

Though, apparently the formatting used here predates your changes; you simply moved the code (and comment) around.

Show 11 quoted lines
> +       opt->extra_notes_refs.strdup_strings = 1;
> +       string_list_clear(&opt->extra_notes_refs, 0);
> +       opt->extra_notes_refs.strdup_strings = 0;
> +       *show_notes = 0;
>  }
> diff --git a/notes.h b/notes.h
> @@ -266,14 +266,19 @@ struct display_notes_opt {
>  /*
> + * This family of functions enables or disables the display of notes. In
> + * particular, 'enable_default_display_notes' will display the default notes,
> + * 'enable_default_display_notes' will display the notes ref 'ref' and
s/enable_default_display_notes/enable_ref_display_notes/
> + * 'disable_display_notes' will disable notes, including those added by previous
> + * invocations of the 'enable_*_display_notes' functions.
> + *
> + * 'show_notes' is a points to a boolean which will be set to 1 if notes are
s/points/pointer/
> + * displayed, else 0. It must not be NULL.
>   */
Previous: Denton LiuNext: Denton Liu
Message 4 of 5 in “dl/format-patch-notes-config-fixup: clean up some leftoverbits”
  1. 0/2 dl/format-patch-notes-config-fixup: clean up some leftoverbitsDenton Liu, Dec 12, 2019
  2. 1/2 config/format.txt: clarify behavior of multiple format.notesDenton Liu, Dec 12, 2019
  3. 2/2 notes: break set_display_notes() into smaller functionsDenton Liu, Dec 12, 2019
  4. Eric SunshineDec 18, 2019
  5. notes.h: fix typos in commentDenton Liu, Dec 18, 2019

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.