serve.[ch]: remove "serve_options", split up --advertise-refs code
[alt-git.git] / t / helper / test-serve-v2.c
blob28e905afc36afdc3202ec68ac915b1ddc6a08781
1 #include "test-tool.h"
2 #include "cache.h"
3 #include "parse-options.h"
4 #include "serve.h"
6 static char const * const serve_usage[] = {
7 N_("test-tool serve-v2 [<options>]"),
8 NULL
9 };
11 int cmd__serve_v2(int argc, const char **argv)
13 int stateless_rpc = 0;
14 int advertise_capabilities = 0;
15 struct option options[] = {
16 OPT_BOOL(0, "stateless-rpc", &stateless_rpc,
17 N_("quit after a single request/response exchange")),
18 OPT_BOOL(0, "advertise-capabilities", &advertise_capabilities,
19 N_("exit immediately after advertising capabilities")),
20 OPT_END()
22 const char *prefix = setup_git_directory();
24 /* ignore all unknown cmdline switches for now */
25 argc = parse_options(argc, argv, prefix, options, serve_usage,
26 PARSE_OPT_KEEP_DASHDASH |
27 PARSE_OPT_KEEP_UNKNOWN);
29 if (advertise_capabilities)
30 protocol_v2_advertise_capabilities();
31 else
32 protocol_v2_serve_loop(stateless_rpc);
34 return 0;