Skip to content

Commit 98e2d9d

Browse files
avargitster
authored andcommitted
upload-pack: document and rename --advertise-refs
The --advertise-refs documentation in git-upload-pack added in 9812f21 (upload-pack.c: use parse-options API, 2016-05-31) hasn't been entirely true ever since v2 support was implemented in e52449b (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f234da8 commit 98e2d9d

File tree

8 files changed

+39
-8
lines changed

8 files changed

+39
-8
lines changed

Documentation/git-receive-pack.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ OPTIONS
4141
<directory>::
4242
The repository to sync into.
4343

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+
4449
PRE-RECEIVE HOOK
4550
----------------
4651
Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists

Documentation/git-upload-pack.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ OPTIONS
3636
This fits with the HTTP POST request processing model where
3737
a program may read the request, write a response, and must exit.
3838

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].
4347

4448
<directory>::
4549
The repository to sync from.

Documentation/technical/http-protocol.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ The client may send Extra Parameters (see
225225
Documentation/technical/pack-protocol.txt) as a colon-separated string
226226
in the Git-Protocol HTTP header.
227227

228+
Uses the `--http-backend-info-refs` option to
229+
linkgit:git-upload-pack[1].
230+
228231
Dumb Server Response
229232
^^^^^^^^^^^^^^^^^^^^
230233
Dumb servers MUST respond with the dumb server reply format.

Documentation/technical/protocol-v2.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ A v2 server would reply:
8181
Subsequent requests are then made directly to the service
8282
`$GIT_URL/git-upload-pack`. (This works the same for git-receive-pack).
8383

84+
Uses the `--http-backend-info-refs` option to
85+
linkgit:git-upload-pack[1].
86+
8487
Capability Advertisement
8588
------------------------
8689

builtin/receive-pack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2477,7 +2477,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
24772477
struct option options[] = {
24782478
OPT__QUIET(&quiet, N_("quiet")),
24792479
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"),
24812482
OPT_HIDDEN_BOOL(0, "reject-thin-pack-for-testing", &reject_thin, NULL),
24822483
OPT_END()
24832484
};

builtin/upload-pack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix)
2222
struct option options[] = {
2323
OPT_BOOL(0, "stateless-rpc", &stateless_rpc,
2424
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"),
2728
OPT_BOOL(0, "strict", &strict,
2829
N_("do not try <directory>/.git/ if <directory> is no Git directory")),
2930
OPT_INTEGER(0, "timeout", &timeout,

http-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
534534

535535
if (service_name) {
536536
const char *argv[] = {NULL /* service name */,
537-
"--advertise-refs",
537+
"--http-backend-info-refs",
538538
".", NULL};
539539
struct rpc_service *svc = select_service(hdr, service_name);
540540

t/t5555-http-smart-common.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ test_expect_success 'setup' '
88
test_commit --no-tag initial
99
'
1010

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+
1125
test_expect_success 'git upload-pack --advertise-refs' '
1226
cat >expect <<-EOF &&
1327
$(git rev-parse HEAD) HEAD

0 commit comments

Comments
 (0)