Subject: Re: [PATCH v3 05/12] list-objects: consolidate traverse_commit_list[_filtered]

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Wed, 09 Mar 2022 14:24:13 +0100

On Tue, Mar 08 2022, Derrick Stolee via GitGitGadget wrote:

> From: Derrick Stolee <[email-masked]>
> [...]
>  void traverse_commit_list_filtered(
> -	struct list_objects_filter_options *filter_options,
>  	struct rev_info *revs,
>  	show_commit_fn show_commit,
>  	show_object_fn show_object,
> @@ -444,7 +429,13 @@ void traverse_commit_list_filtered(
>  	ctx.show_object = show_object;
>  	ctx.show_commit = show_commit;
>  	ctx.show_data = show_data;
> -	ctx.filter = list_objects_filter__init(omitted, filter_options);
> +	if (revs->filter)
> +		ctx.filter = list_objects_filter__init(omitted, revs->filter);
> +	else
> +		ctx.filter = NULL;
> +

Purely an optional nit, but here we could also let the initializer take
care of the default NULL-ing:

diff --git a/list-objects.c b/list-objects.c
index 2f623f82115..52c19d54019 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -421,12 +421,14 @@ void traverse_commit_list(struct rev_info *revs,
 			  show_object_fn show_object,
 			  void *show_data)
 {
-	struct traversal_context ctx;
-	ctx.revs = revs;
-	ctx.show_commit = show_commit;
-	ctx.show_object = show_object;
-	ctx.show_data = show_data;
-	ctx.filter = NULL;
+	struct traversal_context ctx = {
+		.revs = revs,
+		.show_commit = show_commit,
+		ctx.show_object = show_object,
+		ctx.show_data = show_data,
+	};
+	if (revs->filter)
+		ctx.filter = ...;
 	do_traverse(&ctx);
 }