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

Re: [PATCH 1/2] diff.[ch]: have diff_free() call clear_pathspec(opts.pathspec)

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 16, 2022, 21:48 UTC
Message-ID
<xmqqh78ycwjc.fsf@gitster.g>
In-Reply-To
<patch-1.2-1c6c7f0f52f-20220216T105250Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 12 quoted lines
> diff --git a/diff.c b/diff.c
> index c862771a589..0aef3db6e10 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -6345,6 +6345,7 @@ void diff_free(struct diff_options *options)
>  
>  	diff_free_file(options);
>  	diff_free_ignore_regex(options);
> +	clear_pathspec(&options->pathspec);
>  }
>  
>  void diff_flush(struct diff_options *options)

Interesting. As diff_flush() is the way to conclude the diff session whose state was kept in the diff_options structure, it probably makes sense to allow pathspec to be also cleared from there. It is somewhat surprising that we didn't do this when we introduced diff_free(), but better late than never ;-)

Show 20 quoted lines
> diff --git a/notes-merge.c b/notes-merge.c
> index b4a3a903e86..7ba40cfb080 100644
> --- a/notes-merge.c
> +++ b/notes-merge.c
> @@ -175,7 +175,6 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
>  		       oid_to_hex(&mp->remote));
>  	}
>  	diff_flush(&opt);
> -	clear_pathspec(&opt.pathspec);
>  
>  	*num_changes = len;
>  	return changes;
> @@ -261,7 +260,6 @@ static void diff_tree_local(struct notes_merge_options *o,
>  		       oid_to_hex(&mp->local));
>  	}
>  	diff_flush(&opt);
> -	clear_pathspec(&opt.pathspec);
>  }
>  
>  static void check_notes_merge_worktree(struct notes_merge_options *o)
Looks quite sensible.  Will queue.  Thanks.
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 5 of 8 in “diff_free(): free a bit more, fix leaks”
  1. 0/2 diff_free(): free a bit more, fix leaksÆvar Arnfjörð Bjarmason, Feb 16, 2022
  2. 1/2 diff.[ch]: have diff_free() call clear_pathspec(opts.pathspec)Ævar Arnfjörð Bjarmason, Feb 16, 2022
  3. Elijah NewrenFeb 16, 2022
  4. Ævar Arnfjörð BjarmasonFeb 17, 2022
  5. Junio C HamanoFeb 16, 2022
  6. 2/2 diff.[ch]: have diff_free() free options->parseoptsÆvar Arnfjörð Bjarmason, Feb 16, 2022
  7. Elijah NewrenFeb 16, 2022
  8. Elijah NewrenFeb 16, 2022

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.