Skip to content

Commit b9ea214

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a08a83d commit b9ea214

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

list-objects-filter-options.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ static int parse_combine_filter(
1515
const char *arg,
1616
struct strbuf *errbuf);
1717

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+
1841
/*
1942
* Parse value of the argument to the "filter" keyword.
2043
* On the command line this looks like:

list-objects-filter-options.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ enum list_objects_filter_choice {
1717
LOFC__COUNT /* must be last */
1818
};
1919

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+
2026
struct list_objects_filter_options {
2127
/*
2228
* 'filter_spec' is the raw argument value given on the command line

0 commit comments

Comments
 (0)