OSDN Git Service

list-objects-filter-options: support --no-filter
authorJeff Hostetler <jeffhost@microsoft.com>
Tue, 5 Dec 2017 16:50:13 +0000 (16:50 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Dec 2017 17:44:36 +0000 (09:44 -0800)
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>
Documentation/git-pack-objects.txt
list-objects-filter-options.c
list-objects-filter-options.h

index b924c6c..aa403d0 100644 (file)
@@ -242,6 +242,9 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
        the resulting packfile.  See linkgit:git-rev-list[1] for valid
        `<filter-spec>` forms.
 
+--no-filter::
+       Turns off any previous `--filter=` argument.
+
 --missing=<missing-action>::
        A debug option to help with future "partial clone" development.
        This option specifies how missing objects are handled.
index 52bdec7..4c5b34e 100644 (file)
@@ -74,8 +74,19 @@ int opt_parse_list_objects_filter(const struct option *opt,
 {
        struct list_objects_filter_options *filter_options = opt->value;
 
-       assert(arg);
-       assert(!unset);
+       if (unset || !arg) {
+               list_objects_filter_release(filter_options);
+               return 0;
+       }
 
        return parse_list_objects_filter(filter_options, arg);
 }
+
+void list_objects_filter_release(
+       struct list_objects_filter_options *filter_options)
+{
+       free(filter_options->filter_spec);
+       free(filter_options->sparse_oid_value);
+       free(filter_options->sparse_path_value);
+       memset(filter_options, 0, sizeof(*filter_options));
+}
index dd7e5db..eea44a1 100644 (file)
@@ -52,7 +52,10 @@ int opt_parse_list_objects_filter(const struct option *opt,
 
 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
        { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
-         N_("object filtering"), PARSE_OPT_NONEG, \
+         N_("object filtering"), 0, \
          opt_parse_list_objects_filter }
 
+void list_objects_filter_release(
+       struct list_objects_filter_options *filter_options);
+
 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */