mirror of
https://github.com/git/git.git
synced 2024-12-24 09:13:59 +08:00
98e2d9d6f7
The --advertise-refs documentation in git-upload-pack added in9812f2136b
(upload-pack.c: use parse-options API, 2016-05-31) hasn't been entirely true ever since v2 support was implemented ine52449b672
(connect: request remote refs using v2, 2018-03-15). Under v2 we don't advertise the refs at all, but rather dump the capabilities header. This option has always been an obscure internal implementation detail, it wasn't even documented for git-receive-pack. Since it has exactly one user let's rename it to --http-backend-info-refs, which is more accurate and points the reader in the right direction. Let's also cross-link this from the protocol v1 and v2 documentation. I'm retaining a hidden --advertise-refs alias in case there's any external users of this, and making both options hidden to the bash completion (as with most other internal-only options). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
75 lines
1.9 KiB
C
75 lines
1.9 KiB
C
#include "cache.h"
|
|
#include "builtin.h"
|
|
#include "exec-cmd.h"
|
|
#include "pkt-line.h"
|
|
#include "parse-options.h"
|
|
#include "protocol.h"
|
|
#include "upload-pack.h"
|
|
#include "serve.h"
|
|
|
|
static const char * const upload_pack_usage[] = {
|
|
N_("git upload-pack [<options>] <dir>"),
|
|
NULL
|
|
};
|
|
|
|
int cmd_upload_pack(int argc, const char **argv, const char *prefix)
|
|
{
|
|
const char *dir;
|
|
int strict = 0;
|
|
int advertise_refs = 0;
|
|
int stateless_rpc = 0;
|
|
int timeout = 0;
|
|
struct option options[] = {
|
|
OPT_BOOL(0, "stateless-rpc", &stateless_rpc,
|
|
N_("quit after a single request/response exchange")),
|
|
OPT_HIDDEN_BOOL(0, "http-backend-info-refs", &advertise_refs,
|
|
N_("serve up the info/refs for git-http-backend")),
|
|
OPT_ALIAS(0, "advertise-refs", "http-backend-info-refs"),
|
|
OPT_BOOL(0, "strict", &strict,
|
|
N_("do not try <directory>/.git/ if <directory> is no Git directory")),
|
|
OPT_INTEGER(0, "timeout", &timeout,
|
|
N_("interrupt transfer after <n> seconds of inactivity")),
|
|
OPT_END()
|
|
};
|
|
|
|
packet_trace_identity("upload-pack");
|
|
read_replace_refs = 0;
|
|
|
|
argc = parse_options(argc, argv, prefix, options, upload_pack_usage, 0);
|
|
|
|
if (argc != 1)
|
|
usage_with_options(upload_pack_usage, options);
|
|
|
|
setup_path();
|
|
|
|
dir = argv[0];
|
|
|
|
if (!enter_repo(dir, strict))
|
|
die("'%s' does not appear to be a git repository", dir);
|
|
|
|
switch (determine_protocol_version_server()) {
|
|
case protocol_v2:
|
|
if (advertise_refs)
|
|
protocol_v2_advertise_capabilities();
|
|
else
|
|
protocol_v2_serve_loop(stateless_rpc);
|
|
break;
|
|
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(advertise_refs, stateless_rpc, timeout);
|
|
break;
|
|
case protocol_unknown_version:
|
|
BUG("unknown protocol version");
|
|
}
|
|
|
|
return 0;
|
|
}
|