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