On Tue, Feb 05, 2019 at 04:21:15PM -0800, Jonathan Tan wrote: > Define a GIT_TEST_PROTOCOL_VERSION environment variable meant to be used > from tests. When set, this ensures protocol.version is at least the > given value, 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_PROTOCOL_VERSION is > unset, set to 0, or set to 1. Some tests fail when > GIT_TEST_PROTOCOL_VERSION is set to 2, but this will be dealt with in > subsequent patches. Makes sense. The "at least" part made me scratch my head at first, but your explanation in response to Ævar made sense. Two minor nits: > diff --git a/protocol.c b/protocol.c > index 5664bd7a05..c7a735bfa2 100644 > --- a/protocol.c > +++ b/protocol.c > @@ -42,6 +42,10 @@ static const char *format_protocol_version(enum protocol_version version) > enum protocol_version get_protocol_version_config(void) > { > const char *value; > + enum protocol_version retval = protocol_v0; > + const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION"; > + const char *git_test_v = getenv(git_test_k); We've discussed recently how the return value from getenv() isn't stable. It looks like we could assign it much closer to the point-of-use here (which still isn't 100% foolproof, but I think is something we could encourage as a general pattern, and mostly works due to our ring-buffer technique). I.e., right before this conditional: > + > + if (git_test_v && strlen(git_test_v)) { It's more idiomatic in our code base to check for a non-empty string as: if (git_test_v && *git_test_v) though obviously that's pretty minor. -Peff