@@ -19,12 +19,24 @@ static int always_advertise(struct repository *r,
return 1;
}
-static int never_advertise(struct repository *r,
- struct strbuf *value)
+static int key_serve_prefix(const char *key, const char *value, void *data)
{
+ int *signal = data;
+ if (!strncmp(key, "serve.", 6)) {
+ *signal = 1;
+ return 1;
+ }
return 0;
}
+static int has_serve_config(struct repository *r,
+ struct strbuf *value)
+{
+ int signal = 0;
+ repo_config(r, key_serve_prefix, &signal);
+ return signal;
+}
+
static int agent_advertise(struct repository *r,
struct strbuf *value)
{
@@ -121,7 +133,7 @@ static struct protocol_capability capabilities[] = {
},
{
.name = "features",
- .advertise = never_advertise,
+ .advertise = has_serve_config,
.command = cap_features,
},
{
@@ -33,6 +33,15 @@ test_expect_success 'test capability advertisement' '
test_cmp expect actual
'
+test_expect_success 'test capability advertisement' '
+ test_when_finished git config --unset serve.bundleuri &&
+ git config serve.bundleuri "file://$(pwd)" &&
+ GIT_TEST_SIDEBAND_ALL=0 test-tool serve-v2 \
+ --advertise-capabilities >out &&
+ test-tool pkt-line unpack <out >actual &&
+ grep features actual
+'
+
test_expect_success 'stateless-rpc flag does not list capabilities' '
# Empty request
test-tool pkt-line pack >in <<-EOF &&