Skip to content

Commit 4875c97

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1dde5fa commit 4875c97

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Documentation/git-pack-objects.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
242242
the resulting packfile. See linkgit:git-rev-list[1] for valid
243243
`<filter-spec>` forms.
244244

245+
--no-filter::
246+
Turns off any previous `--filter=` argument.
247+
245248
--missing=<missing-action>::
246249
A debug option to help with future "partial clone" development.
247250
This option specifies how missing objects are handled.

list-objects-filter-options.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,19 @@ int opt_parse_list_objects_filter(const struct option *opt,
7474
{
7575
struct list_objects_filter_options *filter_options = opt->value;
7676

77-
assert(arg);
78-
assert(!unset);
77+
if (unset || !arg) {
78+
list_objects_filter_release(filter_options);
79+
return 0;
80+
}
7981

8082
return parse_list_objects_filter(filter_options, arg);
8183
}
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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ int opt_parse_list_objects_filter(const struct option *opt,
5252

5353
#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
5454
{ OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
55-
N_("object filtering"), PARSE_OPT_NONEG, \
55+
N_("object filtering"), 0, \
5656
opt_parse_list_objects_filter }
5757

58+
void list_objects_filter_release(
59+
struct list_objects_filter_options *filter_options);
60+
5861
#endif /* LIST_OBJECTS_FILTER_OPTIONS_H */

0 commit comments

Comments
 (0)