Skip to content

Commit 5bf7f1e

Browse files
peffgitster
authored andcommitted
list-objects-filter: treat NULL filter_options as "disabled"
In most callers, we have an actual list_objects_filter_options struct, and if no filtering is desired its "choice" element will be LOFC_DISABLED. However, some code may have only a pointer to such a struct which may be NULL (because _their_ callers didn't care about filtering, either). Rather than forcing them to handle this explicitly like: if (filter_options) traverse_commit_list_filtered(filter_options, revs, show_commit, show_object, show_data, NULL); else traverse_commit_list(revs, show_commit, show_object, show_data); let's just treat a NULL filter_options the same as LOFC_DISABLED. We only need a small change, since that option struct is converted into a real filter only in the "init" function. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b34789c commit 5bf7f1e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

list-objects-filter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,9 @@ struct filter *list_objects_filter__init(
663663

664664
assert((sizeof(s_filters) / sizeof(s_filters[0])) == LOFC__COUNT);
665665

666+
if (!filter_options)
667+
return NULL;
668+
666669
if (filter_options->choice >= LOFC__COUNT)
667670
BUG("invalid list-objects filter choice: %d",
668671
filter_options->choice);

0 commit comments

Comments
 (0)