MCPcopy Create free account
hub / github.com/git/git / cmd__bundle_uri_parse

Function cmd__bundle_uri_parse

t/helper/test-bundle-uri.c:15–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13};
14
15static int cmd__bundle_uri_parse(int argc, const char **argv, enum input_mode mode)
16{
17 const char *key_value_usage[] = {
18 "test-tool bundle-uri parse-key-values <input>",
19 NULL
20 };
21 const char *config_usage[] = {
22 "test-tool bundle-uri parse-config <input>",
23 NULL
24 };
25 const char **usage = key_value_usage;
26 struct option options[] = {
27 OPT_END(),
28 };
29 struct strbuf sb = STRBUF_INIT;
30 struct bundle_list list;
31 int err = 0;
32 FILE *fp;
33
34 if (mode == CONFIG_FILE)
35 usage = config_usage;
36
37 argc = parse_options(argc, argv, NULL, options, usage,
38 PARSE_OPT_STOP_AT_NON_OPTION);
39
40 init_bundle_list(&list);
41
42 list.baseURI = xstrdup("<uri>");
43
44 switch (mode) {
45 case KEY_VALUE_PAIRS:
46 if (argc != 1)
47 goto usage;
48 fp = fopen(argv[0], "r");
49 if (!fp)
50 die("failed to open '%s'", argv[0]);
51 while (strbuf_getline(&sb, fp) != EOF) {
52 if (bundle_uri_parse_line(&list, sb.buf))
53 err = error("bad line: '%s'", sb.buf);
54 }
55 fclose(fp);
56 break;
57
58 case CONFIG_FILE:
59 if (argc != 1)
60 goto usage;
61 err = bundle_uri_parse_config_format("<uri>", argv[0], &list);
62 break;
63 }
64 strbuf_release(&sb);
65
66 print_bundle_list(stdout, &list);
67
68 clear_bundle_list(&list);
69
70 return !!err;
71
72usage:

Callers 1

cmd__bundle_uriFunction · 0.85

Calls 12

parse_optionsFunction · 0.85
init_bundle_listFunction · 0.85
xstrdupFunction · 0.85
strbuf_getlineFunction · 0.85
bundle_uri_parse_lineFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
print_bundle_listFunction · 0.85
clear_bundle_listFunction · 0.85
usage_with_optionsFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected