aboutsummaryrefslogtreecommitdiffstats
path: root/list-objects-filter-options.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-04-03 15:03:05 -0700
committerJunio C Hamano <gitster@pobox.com>2022-04-03 15:03:05 -0700
commit1e2574e5854e989f17d44f505f73278455b28eeb (patch)
tree6d119a7ce6b96849436fda023e5980d2ce8c6a24 /list-objects-filter-options.h
parentThe 14th batch (diff)
parentpack-objects: lazily set up "struct rev_info", don't leak (diff)
downloadgit-1e2574e5854e989f17d44f505f73278455b28eeb.tar.gz
git-1e2574e5854e989f17d44f505f73278455b28eeb.zip
Merge branch 'ds/partial-bundle-more' into ab/plug-leak-in-revisions
* ds/partial-bundle-more: pack-objects: lazily set up "struct rev_info", don't leak bundle: output hash information in 'verify' bundle: move capabilities to end of 'verify' pack-objects: parse --filter directly into revs.filter pack-objects: move revs out of get_object_list() list-objects-filter: remove CL_ARG__FILTER
Diffstat (limited to 'list-objects-filter-options.h')
-rw-r--r--list-objects-filter-options.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index 2eb6c98394..ffc02d77e7 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -69,9 +69,6 @@ struct list_objects_filter_options {
*/
};
-/* Normalized command line arguments */
-#define CL_ARG__FILTER "filter"
-
/*
* Parse value of the argument to the "filter" keyword.
* On the command line this looks like:
@@ -107,13 +104,31 @@ void parse_list_objects_filter(
struct list_objects_filter_options *filter_options,
const char *arg);
+/**
+ * The opt->value to opt_parse_list_objects_filter() is either a
+ * "struct list_objects_filter_option *" when using
+ * OPT_PARSE_LIST_OBJECTS_FILTER().
+ *
+ * Or, if using no "struct option" field is used by the callback,
+ * except the "defval" which is expected to be an "opt_lof_init"
+ * function, which is called with the "opt->value" and must return a
+ * pointer to the ""struct list_objects_filter_option *" to be used.
+ *
+ * The OPT_PARSE_LIST_OBJECTS_FILTER_INIT() can be used e.g. the
+ * "struct list_objects_filter_option" is embedded in a "struct
+ * rev_info", which the "defval" could be tasked with lazily
+ * initializing. See cmd_pack_objects() for an example.
+ */
int opt_parse_list_objects_filter(const struct option *opt,
const char *arg, int unset);
+typedef struct list_objects_filter_options *(*opt_lof_init)(void *);
+#define OPT_PARSE_LIST_OBJECTS_FILTER_INIT(fo, init) \
+ { OPTION_CALLBACK, 0, "filter", (fo), N_("args"), \
+ N_("object filtering"), 0, opt_parse_list_objects_filter, \
+ (intptr_t)(init) }
#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
- OPT_CALLBACK(0, CL_ARG__FILTER, fo, N_("args"), \
- N_("object filtering"), \
- opt_parse_list_objects_filter)
+ OPT_PARSE_LIST_OBJECTS_FILTER_INIT((fo), NULL)
/*
* Translates abbreviated numbers in the filter's filter_spec into their