diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2009-10-30 17:47:33 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-11-04 17:58:14 -0800 |
commit | 42526b478e369d7e8c9a95186ad87fae9930eea5 (patch) | |
tree | 3e3791a0e156d559341a50598e0adc27fccaf06f /builtin-receive-pack.c | |
parent | 2f4038ab337e55017d4ff21ddbae9427544ca02c (diff) | |
download | git-42526b478e369d7e8c9a95186ad87fae9930eea5.tar.gz |
Add stateless RPC options to upload-pack, receive-pack
When --stateless-rpc is passed as a command line parameter to
upload-pack or receive-pack the programs now assume they may
perform only a single read-write cycle with stdin and stdout.
This fits with the HTTP POST request processing model where a
program may read the request, write a response, and must exit.
When --advertise-refs is passed as a command line parameter only
the initial ref advertisement is output, and the program exits
immediately. This fits with the HTTP GET request model, where
no request content is received but a response must be produced.
HTTP headers and/or environment are not processed here, but
instead are assumed to be handled by the program invoking
either service backend.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-receive-pack.c')
-rw-r--r-- | builtin-receive-pack.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c index b771fe9b20..70ff8c5d75 100644 --- a/builtin-receive-pack.c +++ b/builtin-receive-pack.c @@ -615,6 +615,8 @@ static void add_alternate_refs(void) int cmd_receive_pack(int argc, const char **argv, const char *prefix) { + int advertise_refs = 0; + int stateless_rpc = 0; int i; char *dir = NULL; @@ -623,7 +625,15 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) const char *arg = *argv++; if (*arg == '-') { - /* Do flag handling here */ + if (!strcmp(arg, "--advertise-refs")) { + advertise_refs = 1; + continue; + } + if (!strcmp(arg, "--stateless-rpc")) { + stateless_rpc = 1; + continue; + } + usage(receive_pack_usage); } if (dir) @@ -652,12 +662,16 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) " report-status delete-refs ofs-delta " : " report-status delete-refs "; - add_alternate_refs(); - write_head_info(); - clear_extra_refs(); + if (advertise_refs || !stateless_rpc) { + add_alternate_refs(); + write_head_info(); + clear_extra_refs(); - /* EOF */ - packet_flush(1); + /* EOF */ + packet_flush(1); + } + if (advertise_refs) + return 0; read_head_info(); if (commands) { |