list_objects_filter_options: introduce 'list_object_filter_config_name'
In a subsequent commit, we will add configuration options that are specific to each kind of object filter, in which case it is handy to have a function that translates between 'enum list_objects_filter_choice' and an appropriate configuration-friendly string. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Jul 31, 2020 at 16:26 UTC
b9ea214795b89e0455bbe92fab5d30d1f3a4cc6d
2 files changed
+29
list-objects-filter-options.c
+23
@@ -15,6 +15,29 @@ static int parse_combine_filter(
15
const char *arg,
16
struct strbuf *errbuf);
17
18
+const char *list_object_filter_config_name(enum list_objects_filter_choice c)
19
+{
20
+ switch (c) {
21
+ case LOFC_DISABLED:
22
+ /* we have no name for "no filter at all" */
23
+ break;
24
+ case LOFC_BLOB_NONE:
25
+ return "blob:none";
26
+ case LOFC_BLOB_LIMIT:
27
+ return "blob:limit";
28
+ case LOFC_TREE_DEPTH:
29
+ return "tree";
30
+ case LOFC_SPARSE_OID:
31
+ return "sparse:oid";
32
+ case LOFC_COMBINE:
33
+ return "combine";
34
+ case LOFC__COUNT:
35
+ /* not a real filter type; just the count of all filters */
36
+ break;
37
+ }
38
+ BUG("list_object_filter_choice_name: invalid argument '%d'", c);
39
+}
40
+
41
/*
42
* Parse value of the argument to the "filter" keyword.
43
* On the command line this looks like:
list-objects-filter-options.h
+6
@@ -17,6 +17,12 @@ enum list_objects_filter_choice {
17
LOFC__COUNT /* must be last */
18
};
19
20
+/*
21
+ * Returns a configuration key suitable for describing the given object filter,
22
+ * e.g.: "blob:none", "combine", etc.
23
+ */
24
+const char *list_object_filter_config_name(enum list_objects_filter_choice c);
25
+
26
struct list_objects_filter_options {
27
/*
28
* 'filter_spec' is the raw argument value given on the command line