summaryrefslogtreecommitdiff
path: root/list-objects-filter-options.h
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2017-11-21 20:58:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-22 05:11:57 (GMT)
commit25ec7bcac044057900a0f3c9a8d6ccbb41a066bc (patch)
tree115a72c755c0578349d3cf08bef0b0883fd4153e /list-objects-filter-options.h
parentc3a9ad311793e16f6f5c5dcc3559133700c70288 (diff)
downloadgit-25ec7bcac044057900a0f3c9a8d6ccbb41a066bc.zip
git-25ec7bcac044057900a0f3c9a8d6ccbb41a066bc.tar.gz
git-25ec7bcac044057900a0f3c9a8d6ccbb41a066bc.tar.bz2
list-objects: filter objects in traverse_commit_list
Create traverse_commit_list_filtered() and add filtering interface to allow certain objects to be omitted from the traversal. Update traverse_commit_list() to be a wrapper for the above with a null filter to minimize the number of callers that needed to be changed. Object filtering will be used in a future commit by rev-list and pack-objects for partial clone and fetch to omit unwanted objects from the result. traverse_bitmap_commit_list() does not work with filtering. If a packfile bitmap is present, it will not be used. It should be possible to extend such support in the future (at least to simple filters that do not require object pathnames), but that is beyond the scope of this patch series. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects-filter-options.h')
-rw-r--r--list-objects-filter-options.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
new file mode 100644
index 0000000..dd7e5db
--- /dev/null
+++ b/list-objects-filter-options.h
@@ -0,0 +1,58 @@
+#ifndef LIST_OBJECTS_FILTER_OPTIONS_H
+#define LIST_OBJECTS_FILTER_OPTIONS_H
+
+#include "parse-options.h"
+
+/*
+ * The list of defined filters for list-objects.
+ */
+enum list_objects_filter_choice {
+ LOFC_DISABLED = 0,
+ LOFC_BLOB_NONE,
+ LOFC_BLOB_LIMIT,
+ LOFC_SPARSE_OID,
+ LOFC_SPARSE_PATH,
+ LOFC__COUNT /* must be last */
+};
+
+struct list_objects_filter_options {
+ /*
+ * 'filter_spec' is the raw argument value given on the command line
+ * or protocol request. (The part after the "--keyword=".) For
+ * commands that launch filtering sub-processes, this value should be
+ * passed to them as received by the current process.
+ */
+ char *filter_spec;
+
+ /*
+ * 'choice' is determined by parsing the filter-spec. This indicates
+ * the filtering algorithm to use.
+ */
+ enum list_objects_filter_choice choice;
+
+ /*
+ * Parsed values (fields) from within the filter-spec. These are
+ * choice-specific; not all values will be defined for any given
+ * choice.
+ */
+ struct object_id *sparse_oid_value;
+ char *sparse_path_value;
+ unsigned long blob_limit_value;
+};
+
+/* Normalized command line arguments */
+#define CL_ARG__FILTER "filter"
+
+int parse_list_objects_filter(
+ struct list_objects_filter_options *filter_options,
+ const char *arg);
+
+int opt_parse_list_objects_filter(const struct option *opt,
+ const char *arg, int unset);
+
+#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
+ { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
+ N_("object filtering"), PARSE_OPT_NONEG, \
+ opt_parse_list_objects_filter }
+
+#endif /* LIST_OBJECTS_FILTER_OPTIONS_H */