Subject: Re: [PATCH v2 12/27] revisions API users: use release_revisions() in builtin/log.c

From: Junio C Hamano <[email-masked]>
Date: Thu, 24 Mar 2022 18:03:33 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> In preparation for having the "log" family of functions make wider use
> of release_revisions() let's have them call it just before
> exiting. This changes the "log", "whatchanged", "show",
> "format-patch", etc. commands, all of which live in this file.
>
> The release_revisions() API still only frees the "pending" member, but
> will learn to more members of "struct rev_info" in subsequent commits.

Learn to do what to more members?

> In the case of "format-patch" revert the addition of UNLEAK() in
> dee839a2633 (format-patch: mark rev_info with UNLEAK, 2021-12-16), and
> which will cause several tests that previously passed under
> "TEST_PASSES_SANITIZE_LEAK=true" to start failing.

", and which" -> ", which".

> diff --git a/builtin/log.c b/builtin/log.c
> index 6f9928fabfe..c40ebe1c3f4 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -295,6 +295,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
>  	cmd_log_init_finish(argc, argv, prefix, rev, opt);
>  }
>  
> +static int cmd_log_deinit(int ret, struct rev_info *rev)
> +{
> +	release_revisions(rev);
> +	return ret;
> +}

Ugly but cute.

> @@ -732,8 +738,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
>  			ret = error(_("unknown type: %d"), o->type);
>  		}
>  	}
> -	free(objects);
> -	return ret;
> +	return cmd_log_deinit(ret, &rev);
>  }

This probably makes things worse tentatively for OBJ_COMMIT case,
where we reuse the rev structure to "(un)walk" the given commit
after clearing rev.pending, but hopefully you'll fix it up in a
later step or two?