tests: define GIT_TEST_SIDEBAND_ALL

Define a GIT_TEST_SIDEBAND_ALL environment variable meant to be used from tests. When set to true, this overrides uploadpack.allowsidebandall to true, allowing the entire test suite to be run as if this configuration is in place for all repositories. As of this patch, all tests pass whether GIT_TEST_SIDEBAND_ALL is unset or set to 1. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Jan 16, 2019 at 11:28 UTC 07c3c2aa16370fd97551b7d1aa6af3d051e7cf8f
7 files changed +21 -10
fetch-pack.c
+2 -1
@@ -1327,7 +1327,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1327 packet_reader_init(&reader, fd[0], NULL, 0,
1328 PACKET_READ_CHOMP_NEWLINE |
1329 PACKET_READ_DIE_ON_ERR_PACKET);
1330 - if (server_supports_feature("fetch", "sideband-all", 0)) {
1330 + if (git_env_bool("GIT_TEST_SIDEBAND_ALL", 1) &&
1331 + server_supports_feature("fetch", "sideband-all", 0)) {
1332 reader.use_sideband = 1;
1333 reader.me = "fetch-pack";
1334 }
t/README
+5
@@ -358,6 +358,11 @@ GIT_TEST_MULTI_PACK_INDEX=<boolean>, when true, forces the multi-pack-
358 index to be written after every 'git repack' command, and overrides the
359 'core.multiPackIndex' setting to true.
360
361 +GIT_TEST_SIDEBAND_ALL=<boolean>, when true, overrides the
362 +'uploadpack.allowSidebandAll' setting to true, and when false, forces
363 +fetch-pack to not request sideband-all (even if the server advertises
364 +sideband-all).
365 +
366 Naming Tests
367 ------------
368
t/lib-httpd/apache.conf
+1
@@ -78,6 +78,7 @@ PassEnv GNUPGHOME
78 PassEnv ASAN_OPTIONS
79 PassEnv GIT_TRACE
80 PassEnv GIT_CONFIG_NOSYSTEM
81 +PassEnv GIT_TEST_SIDEBAND_ALL
82
83 SetEnvIf Git-Protocol ".*" GIT_PROTOCOL=$0
84
t/t5537-fetch-shallow.sh
+2 -1
@@ -243,7 +243,8 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f
243 "$(git -C "$REPO" rev-parse HEAD)" \
244 "$(git -C "$REPO" rev-parse HEAD^)" \
245 >"$HTTPD_ROOT_PATH/one-time-sed" &&
246 - test_must_fail git -C client fetch --depth=1 "$HTTPD_URL/one_time_sed/repo" \
246 + test_must_fail env GIT_TEST_SIDEBAND_ALL=0 git -C client \
247 + fetch --depth=1 "$HTTPD_URL/one_time_sed/repo" \
248 master:a_branch &&
249
250 # Ensure that the one-time-sed script was used.
t/t5701-git-serve.sh
+1 -1
@@ -14,7 +14,7 @@ test_expect_success 'test capability advertisement' '
14 0000
15 EOF
16
17 - git serve --advertise-capabilities >out &&
17 + GIT_TEST_SIDEBAND_ALL=0 git serve --advertise-capabilities >out &&
18 test-tool pkt-line unpack <out >actual &&
19 test_cmp expect actual
20 '
t/t5702-protocol-v2.sh
+2 -2
@@ -583,8 +583,8 @@ test_expect_success 'when server does not send "ready", expect FLUSH' '
583 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
584 -c protocol.version=2 \
585 fetch "$HTTPD_URL/one_time_sed/http_parent" 2> err &&
586 - grep "fetch< acknowledgments" log &&
587 - ! grep "fetch< ready" log &&
586 + grep "fetch< .*acknowledgments" log &&
587 + ! grep "fetch< .*ready" log &&
588 test_i18ngrep "expected no other sections to be sent after no .ready." err
589 '
590
upload-pack.c
+8 -5
@@ -1288,7 +1288,9 @@ static void process_args(struct packet_reader *request,
1288 continue;
1289 }
1290
1291 - if (allow_sideband_all && !strcmp(arg, "sideband-all")) {
1291 + if ((git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) ||
1292 + allow_sideband_all) &&
1293 + !strcmp(arg, "sideband-all")) {
1294 data->writer.use_sideband = 1;
1295 continue;
1296 }
@@ -1521,10 +1523,11 @@ int upload_pack_advertise(struct repository *r,
1523 allow_ref_in_want)
1524 strbuf_addstr(value, " ref-in-want");
1525
1524 - if (!repo_config_get_bool(the_repository,
1525 - "uploadpack.allowsidebandall",
1526 - &allow_sideband_all_value) &&
1527 - allow_sideband_all_value)
1526 + if (git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) ||
1527 + (!repo_config_get_bool(the_repository,
1528 + "uploadpack.allowsidebandall",
1529 + &allow_sideband_all_value) &&
1530 + allow_sideband_all_value))
1531 strbuf_addstr(value, " sideband-all");
1532 }
1533