list-objects-filter-options: support --no-filter
Teach opt_parse_list_objects_filter() to take --no-filter option and to free the contents of struct filter_options. This command line argument will be automatically inherited by commands using OPT_PARSE_LIST_OBJECTS_FILTER(); this includes pack-objects. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Dec 5, 2017 at 16:50 UTC
4875c9791e787af07992d3ba30061885322b7d11
3 files changed
+20
-3
Documentation/git-pack-objects.txt
+3
@@ -242,6 +242,9 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
242
the resulting packfile. See linkgit:git-rev-list[1] for valid
243
`<filter-spec>` forms.
244
245
+--no-filter::
246
+ Turns off any previous `--filter=` argument.
247
+
248
--missing=<missing-action>::
249
A debug option to help with future "partial clone" development.
250
This option specifies how missing objects are handled.
list-objects-filter-options.c
+13
-2
@@ -74,8 +74,19 @@ int opt_parse_list_objects_filter(const struct option *opt,
74
{
75
struct list_objects_filter_options *filter_options = opt->value;
76
77
- assert(arg);
78
- assert(!unset);
77
+ if (unset || !arg) {
78
+ list_objects_filter_release(filter_options);
79
+ return 0;
80
+ }
81
82
return parse_list_objects_filter(filter_options, arg);
83
}
84
+
85
+void list_objects_filter_release(
86
+ struct list_objects_filter_options *filter_options)
87
+{
88
+ free(filter_options->filter_spec);
89
+ free(filter_options->sparse_oid_value);
90
+ free(filter_options->sparse_path_value);
91
+ memset(filter_options, 0, sizeof(*filter_options));
92
+}
list-objects-filter-options.h
+4
-1
@@ -52,7 +52,10 @@ int opt_parse_list_objects_filter(const struct option *opt,
52
53
#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
54
{ OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
55
- N_("object filtering"), PARSE_OPT_NONEG, \
55
+ N_("object filtering"), 0, \
56
opt_parse_list_objects_filter }
57
58
+void list_objects_filter_release(
59
+ struct list_objects_filter_options *filter_options);
60
+
61
#endif /* LIST_OBJECTS_FILTER_OPTIONS_H */