6 #include "parse-options.h"
8 #include "replace-object.h"
9 #include "upload-pack.h"
12 static const char * const upload_pack_usage
[] = {
13 N_("git-upload-pack [--[no-]strict] [--timeout=<n>] [--stateless-rpc]\n"
14 " [--advertise-refs] <directory>"),
18 int cmd_upload_pack(int argc
, const char **argv
, const char *prefix
)
22 int advertise_refs
= 0;
23 int stateless_rpc
= 0;
25 struct option options
[] = {
26 OPT_BOOL(0, "stateless-rpc", &stateless_rpc
,
27 N_("quit after a single request/response exchange")),
28 OPT_HIDDEN_BOOL(0, "http-backend-info-refs", &advertise_refs
,
29 N_("serve up the info/refs for git-http-backend")),
30 OPT_ALIAS(0, "advertise-refs", "http-backend-info-refs"),
31 OPT_BOOL(0, "strict", &strict
,
32 N_("do not try <directory>/.git/ if <directory> is no Git directory")),
33 OPT_INTEGER(0, "timeout", &timeout
,
34 N_("interrupt transfer after <n> seconds of inactivity")),
38 packet_trace_identity("upload-pack");
39 read_replace_refs
= 0;
41 argc
= parse_options(argc
, argv
, prefix
, options
, upload_pack_usage
, 0);
44 usage_with_options(upload_pack_usage
, options
);
50 if (!enter_repo(dir
, strict
))
51 die("'%s' does not appear to be a git repository", dir
);
53 switch (determine_protocol_version_server()) {
56 protocol_v2_advertise_capabilities();
58 protocol_v2_serve_loop(stateless_rpc
);
62 * v1 is just the original protocol with a version string,
63 * so just fall through after writing the version string.
65 if (advertise_refs
|| !stateless_rpc
)
66 packet_write_fmt(1, "version 1\n");
70 upload_pack(advertise_refs
, stateless_rpc
, timeout
);
72 case protocol_unknown_version
:
73 BUG("unknown protocol version");