upload-pack: document and rename --advertise-refs

The --advertise-refs documentation in git-upload-pack added in 9812f2136b3 (upload-pack.c: use parse-options API, 2016-05-31) hasn't been entirely true ever since v2 support was implemented in e52449b6722 (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>

Ævar Arnfjörð Bjarmason committed Aug 5, 2021 at 03:25 UTC 98e2d9d6f7dc1aff61e99a1daed98e18c7c8526b
8 files changed +39 -8
Documentation/git-receive-pack.txt
+5
@@ -41,6 +41,11 @@ OPTIONS
41 <directory>::
42 The repository to sync into.
43
44 +--http-backend-info-refs::
45 + Used by linkgit:git-http-backend[1] to serve up
46 + `$GIT_URL/info/refs?service=git-receive-pack` requests. See
47 + `--http-backend-info-refs` in linkgit:git-upload-pack[1].
48 +
49 PRE-RECEIVE HOOK
50 ----------------
51 Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists
Documentation/git-upload-pack.txt
+8 -4
@@ -36,10 +36,14 @@ OPTIONS
36 This fits with the HTTP POST request processing model where
37 a program may read the request, write a response, and must exit.
38
39 ---advertise-refs::
40 - Only the initial ref advertisement is output, and the program exits
41 - immediately. This fits with the HTTP GET request model, where
42 - no request content is received but a response must be produced.
39 +--http-backend-info-refs::
40 + Used by linkgit:git-http-backend[1] to serve up
41 + `$GIT_URL/info/refs?service=git-upload-pack` requests. See
42 + "Smart Clients" in link:technical/http-protocol.html[the HTTP
43 + transfer protocols] documentation and "HTTP Transport" in
44 + link:technical/protocol-v2.html[the Git Wire Protocol, Version
45 + 2] documentation. Also understood by
46 + linkgit:git-receive-pack[1].
47
48 <directory>::
49 The repository to sync from.
Documentation/technical/http-protocol.txt
+3
@@ -225,6 +225,9 @@ The client may send Extra Parameters (see
225 Documentation/technical/pack-protocol.txt) as a colon-separated string
226 in the Git-Protocol HTTP header.
227
228 +Uses the `--http-backend-info-refs` option to
229 +linkgit:git-upload-pack[1].
230 +
231 Dumb Server Response
232 ^^^^^^^^^^^^^^^^^^^^
233 Dumb servers MUST respond with the dumb server reply format.
Documentation/technical/protocol-v2.txt
+3
@@ -81,6 +81,9 @@ A v2 server would reply:
81 Subsequent requests are then made directly to the service
82 `$GIT_URL/git-upload-pack`. (This works the same for git-receive-pack).
83
84 +Uses the `--http-backend-info-refs` option to
85 +linkgit:git-upload-pack[1].
86 +
87 Capability Advertisement
88 ------------------------
89
builtin/receive-pack.c
+2 -1
@@ -2477,7 +2477,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
2477 struct option options[] = {
2478 OPT__QUIET(&quiet, N_("quiet")),
2479 OPT_HIDDEN_BOOL(0, "stateless-rpc", &stateless_rpc, NULL),
2480 - OPT_HIDDEN_BOOL(0, "advertise-refs", &advertise_refs, NULL),
2480 + OPT_HIDDEN_BOOL(0, "http-backend-info-refs", &advertise_refs, NULL),
2481 + OPT_ALIAS(0, "advertise-refs", "http-backend-info-refs"),
2482 OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL),
2483 OPT_END()
2484 };
builtin/upload-pack.c
+3 -2
@@ -22,8 +22,9 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix)
22 struct option options[] = {
23 OPT_BOOL(0, "stateless-rpc", &stateless_rpc,
24 N_("quit after a single request/response exchange")),
25 - OPT_BOOL(0, "advertise-refs", &advertise_refs,
26 - N_("exit immediately after initial ref advertisement")),
25 + OPT_HIDDEN_BOOL(0, "http-backend-info-refs", &advertise_refs,
26 + N_("serve up the info/refs for git-http-backend")),
27 + OPT_ALIAS(0, "advertise-refs", "http-backend-info-refs"),
28 OPT_BOOL(0, "strict", &strict,
29 N_("do not try <directory>/.git/ if <directory> is no Git directory")),
30 OPT_INTEGER(0, "timeout", &timeout,
http-backend.c
+1 -1
@@ -534,7 +534,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
534
535 if (service_name) {
536 const char *argv[] = {NULL /* service name */,
537 - "--advertise-refs",
537 + "--http-backend-info-refs",
538 ".", NULL};
539 struct rpc_service *svc = select_service(hdr, service_name);
540
t/t5555-http-smart-common.sh
+14
@@ -8,6 +8,20 @@ test_expect_success 'setup' '
8 test_commit --no-tag initial
9 '
10
11 +test_expect_success 'git upload-pack --http-backend-info-refs and --advertise-refs are aliased' '
12 + git upload-pack --http-backend-info-refs . >expected 2>err.expected &&
13 + git upload-pack --advertise-refs . >actual 2>err.actual &&
14 + test_cmp err.expected err.actual &&
15 + test_cmp expected actual
16 +'
17 +
18 +test_expect_success 'git receive-pack --http-backend-info-refs and --advertise-refs are aliased' '
19 + git receive-pack --http-backend-info-refs . >expected 2>err.expected &&
20 + git receive-pack --advertise-refs . >actual 2>err.actual &&
21 + test_cmp err.expected err.actual &&
22 + test_cmp expected actual
23 +'
24 +
25 test_expect_success 'git upload-pack --advertise-refs' '
26 cat >expect <<-EOF &&
27 $(git rev-parse HEAD) HEAD