MCPcopy Index your code
hub / github.com/git/git / parse_flags

Function parse_flags

t/helper/test-ref-store.c:24–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 }
23
24static unsigned int parse_flags(const char *str, struct flag_definition *defs)
25{
26 struct string_list masks = STRING_LIST_INIT_DUP;
27 unsigned int result = 0;
28
29 if (!strcmp(str, "0"))
30 return 0;
31
32 string_list_split(&masks, str, ",", 64);
33 for (size_t i = 0; i < masks.nr; i++) {
34 const char *name = masks.items[i].string;
35 struct flag_definition *def = defs;
36 int found = 0;
37 while (def->name) {
38 if (!strcmp(def->name, name)) {
39 result |= def->mask;
40 found = 1;
41 break;
42 }
43 def++;
44 }
45 if (!found)
46 die("unknown flag \"%s\"", name);
47 }
48
49 string_list_clear(&masks, 0);
50 return result;
51}
52
53static struct flag_definition empty_flags[] = { { NULL, 0 } };
54

Callers 1

arg_flagsFunction · 0.85

Calls 3

string_list_splitFunction · 0.85
string_list_clearFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected