| 1 | #define USE_THE_REPOSITORY_VARIABLE |
| 2 | |
| 3 | #include "test-tool.h" |
| 4 | #include "gettext.h" |
| 5 | #include "parse-options.h" |
| 6 | #include "repository.h" |
| 7 | #include "serve.h" |
| 8 | #include "setup.h" |
| 9 | |
| 10 | static char const * const serve_usage[] = { |
| 11 | N_("test-tool serve-v2 [<options>]"), |
| 12 | NULL |
| 13 | }; |
| 14 | |
| 15 | int cmd__serve_v2(int argc, const char **argv) |
| 16 | { |
| 17 | int stateless_rpc = 0; |
| 18 | int advertise_capabilities = 0; |
| 19 | struct option options[] = { |
| 20 | OPT_BOOL(0, "stateless-rpc", &stateless_rpc, |
| 21 | N_("quit after a single request/response exchange")), |
| 22 | OPT_BOOL(0, "advertise-capabilities", &advertise_capabilities, |
| 23 | N_("exit immediately after advertising capabilities")), |
| 24 | OPT_END() |
| 25 | }; |
| 26 | const char *prefix = setup_git_directory(the_repository); |
| 27 | |
| 28 | /* ignore all unknown cmdline switches for now */ |
| 29 | argc = parse_options(argc, argv, prefix, options, serve_usage, |
| 30 | PARSE_OPT_KEEP_DASHDASH | |
| 31 | PARSE_OPT_KEEP_UNKNOWN_OPT); |
| 32 | |
| 33 | if (advertise_capabilities) |
| 34 | protocol_v2_advertise_capabilities(the_repository); |
| 35 | else |
| 36 | protocol_v2_serve_loop(the_repository, stateless_rpc); |
| 37 | |
| 38 | return 0; |
| 39 | } |