Brandon Williams <[email protected]> writes:
> +static struct protocol_capability *get_capability(const char *key)
> +{
> + int i;
> +
> + if (!key)
> + return NULL;
> +
> + for (i = 0; i < ARRAY_SIZE(capabilities); i++) {
> + struct protocol_capability *c = &capabilities[i];
> + const char *out;
> + if (skip_prefix(key, c->name, &out) && (!*out || *out == '='))
> + return c;
Looks familiar and resembles what was recently discussed on list ;-)
> +int cmd_serve(int argc, const char **argv, const char *prefix)
> +{
> +
> + struct option options[] = {
> + OPT_END()
> + };
> +
> + /* ignore all unknown cmdline switches for now */
> + argc = parse_options(argc, argv, prefix, options, grep_usage,
> + PARSE_OPT_KEEP_DASHDASH |
> + PARSE_OPT_KEEP_UNKNOWN);
> + serve();
> +
> + return 0;
> +}
> ...
> +/* Main serve loop for protocol version 2 */
> +void serve(void)
> +{
> + /* serve by default supports v2 */
> + packet_write_fmt(1, "version 2\n");
> +
> + advertise_capabilities();
> +
> + for (;;)
> + if (process_request())
> + break;
> +}
I am guessing that this would be run just like upload-pack,
i.e. invoked via ssh or via git-daemon, and that is why it can just
assume that fd#0/fd#1 are already connected to the other end. It
may be helpful to document somewhere how we envision to invoke this
program.