Subject: Re: [PATCH 4/6] fast-import: remove dead strbuf

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 28 Mar 2024 09:21:16 +0100

On Fri, Mar 22, 2024 at 12:03:40AM +0000, Thalia Archibald wrote:
> The strbuf in `note_change_n` has been unused since the function was
> created in a8dd2e7d2b (fast-import: Add support for importing commit
> notes, 2009-10-09) and looks to be a fossil from adapting
> `note_change_m`. Remove it.

Just from inspecting the diff it's not clear that it is actually unused
given that we assign `p = uq.buf`. The message here should probably
mention the important detail that `p` is not actually used after the
assignment.

Patrick

> Signed-off-by: Thalia Archibald <[email-masked]>
> ---
>  builtin/fast-import.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> index d6f998f363..ae8494d0ac 100644
> --- a/builtin/fast-import.c
> +++ b/builtin/fast-import.c
> @@ -2458,7 +2458,6 @@ static void file_change_cr(const char *p, struct branch *b, int rename)
>  
>  static void note_change_n(const char *p, struct branch *b, unsigned char *old_fanout)
>  {
> -	static struct strbuf uq = STRBUF_INIT;
>  	struct object_entry *oe;
>  	struct branch *s;
>  	struct object_id oid, commit_oid;
> @@ -2523,10 +2522,6 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
>  		die("Invalid ref name or SHA1 expression: %s", p);
>  
>  	if (inline_data) {
> -		if (p != uq.buf) {
> -			strbuf_addstr(&uq, p);
> -			p = uq.buf;
> -		}
>  		read_next_command();
>  		parse_and_store_blob(&last_blob, &oid, 0);
>  	} else if (oe) {
> -- 
> 2.44.0
> 
> 
>