summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-10-16 17:55:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-17 01:51:29 (GMT)
commitaa9bab29b8b5e70be5c89e375bfba6e0051b3682 (patch)
tree47730635438fb2037e99b4f9d7f33edbd55a1c33 /upload-pack.c
parentdfe422d04db56e7306a78fcf5b8e93b6b7f60e34 (diff)
downloadgit-aa9bab29b8b5e70be5c89e375bfba6e0051b3682.zip
git-aa9bab29b8b5e70be5c89e375bfba6e0051b3682.tar.gz
git-aa9bab29b8b5e70be5c89e375bfba6e0051b3682.tar.bz2
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 'upload-pack.c')
-rw-r--r--upload-pack.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 7efff2f..ef99a02 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -18,6 +18,7 @@
#include "parse-options.h"
#include "argv-array.h"
#include "prio-queue.h"
+#include "protocol.h"
static const char * const upload_pack_usage[] = {
N_("git upload-pack [<options>] <dir>"),
@@ -1067,6 +1068,23 @@ int cmd_main(int argc, const char **argv)
die("'%s' does not appear to be a git repository", dir);
git_config(upload_pack_config, NULL);
- upload_pack();
+
+ 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:
+ upload_pack();
+ break;
+ case protocol_unknown_version:
+ BUG("unknown protocol version");
+ }
+
return 0;
}