summaryrefslogtreecommitdiff
path: root/list-objects-filter.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-05-04 23:12:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-05 04:57:58 (GMT)
commit5bf7f1eaa51b3f35161e1c9e4d8bc843330dea3c (patch)
tree4947c967130e1c5d322a2fb305fd684c1bd63ebb /list-objects-filter.c
parentb34789c0b0d3b137f0bb516b417bd8d75e0cb306 (diff)
downloadgit-5bf7f1eaa51b3f35161e1c9e4d8bc843330dea3c.zip
git-5bf7f1eaa51b3f35161e1c9e4d8bc843330dea3c.tar.gz
git-5bf7f1eaa51b3f35161e1c9e4d8bc843330dea3c.tar.bz2
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 <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects-filter.c')
-rw-r--r--list-objects-filter.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 1e8d4e7..0a3ef3c 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -663,6 +663,9 @@ struct filter *list_objects_filter__init(
assert((sizeof(s_filters) / sizeof(s_filters[0])) == LOFC__COUNT);
+ if (!filter_options)
+ return NULL;
+
if (filter_options->choice >= LOFC__COUNT)
BUG("invalid list-objects filter choice: %d",
filter_options->choice);