@@ -17,7 +17,18 @@ static enum protocol_version parse_protocol_version(const char *value)
enum protocol_version get_protocol_version_config(void)
{
const char *value;
- if (!git_config_get_string_const("protocol.version", &value)) {
+ const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION";
+ const char *git_test_v = getenv(git_test_k);
+
+ if (git_test_v) {
+ enum protocol_version version = parse_protocol_version(git_test_v);
+
+ if (version == protocol_unknown_version)
+ die("unknown value for %s: %s", git_test_k,
+ git_test_v);
+
+ return version;
+ } else if (!git_config_get_string_const("protocol.version", &value)) {
enum protocol_version version = parse_protocol_version(value);
if (version == protocol_unknown_version)
@@ -358,6 +358,10 @@ GIT_TEST_MULTI_PACK_INDEX=<boolean>, when true, forces the multi-pack-
index to be written after every 'git repack' command, and overrides the
'core.multiPackIndex' setting to true.
+GIT_TEST_PROTOCOL_VERSION=<'protocol.version' config value>, when set,
+runs the test suite with the given protocol.version. E.g. "0", "1" or
+"2".
+
Naming Tests
------------
Add a GIT_TEST_PROTOCOL_VERSION=X test mode which is equivalent to running with protocol.version=X. This is needed to spot regressions and differences such as "ls-refs" behaving differently with transfer.hideRefs. See https://public-inbox.org/git/20181211104236.GA6899@sigill.intra.peff.net/ for a fix for that regression. With this all tests pass with GIT_TEST_PROTOCOL_VERSION=0, but fail with GIT_TEST_PROTOCOL_VERSION=[1|2]. That's OK since this is a new test mode, subsequent patches will fix up these test failures. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- protocol.c | 13 ++++++++++++- t/README | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-)