diff options
author | Brandon Williams <bmwill@google.com> | 2017-10-16 10:55:26 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-17 10:51:29 +0900 |
commit | aa9bab29b8b5e70be5c89e375bfba6e0051b3682 (patch) | |
tree | 47730635438fb2037e99b4f9d7f33edbd55a1c33 /builtin | |
parent | daemon: recognize hidden request arguments (diff) | |
download | tgif-aa9bab29b8b5e70be5c89e375bfba6e0051b3682.tar.xz |
upload-pack, receive-pack: introduce protocol version 1
Teach upload-pack and receive-pack to understand and respond using
protocol version 1, if requested.
Protocol version 1 is simply the original and current protocol (what I'm
calling version 0) with the addition of a single packet line, which
precedes the ref advertisement, indicating the protocol version being
spoken.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/receive-pack.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index dd06b3fb4f..839c1462dc 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -24,6 +24,7 @@ #include "tmp-objdir.h" #include "oidset.h" #include "packfile.h" +#include "protocol.h" static const char * const receive_pack_usage[] = { N_("git receive-pack <git-dir>"), @@ -1963,6 +1964,22 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) else if (0 <= receive_unpack_limit) unpack_limit = receive_unpack_limit; + switch (determine_protocol_version_server()) { + case protocol_v1: + /* + * v1 is just the original protocol with a version string, + * so just fall through after writing the version string. + */ + if (advertise_refs || !stateless_rpc) + packet_write_fmt(1, "version 1\n"); + + /* fallthrough */ + case protocol_v0: + break; + case protocol_unknown_version: + BUG("unknown protocol version"); + } + if (advertise_refs || !stateless_rpc) { write_head_info(); } |