git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ben Peart <benpeart@microsoft.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Cc: "gitster@pobox.com" <gitster@pobox.com>,
	Ben Peart <Ben.Peart@microsoft.com>,
	Ben Peart <Ben.Peart@microsoft.com>
Subject: [PATCH v1] read-cache: add GIT_TEST_INDEX_VERSION support
Date: Wed, 12 Sep 2018 21:26:04 +0000	[thread overview]
Message-ID: <20180912212544.33624-1-benpeart@microsoft.com> (raw)

Teach get_index_format_default() to support running the test suite
with specific index versions.  In particular, this enables the test suite
to be run using index version 4 which is not the default so gets less testing.

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
---

Notes:
    Base Ref: v2.19.0
    Web-Diff: https://github.com/benpeart/git/commit/52e733e2ce
    Checkout: git fetch https://github.com/benpeart/git git-test-index-version-v1 && git checkout 52e733e2ce

 read-cache.c | 47 +++++++++++++++++++++++++++++++++--------------
 t/README     |  6 +++++-
 2 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 7b1354d759..d140ce9989 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1570,26 +1570,45 @@ static unsigned int get_index_format_default(void)
 	char *envversion = getenv("GIT_INDEX_VERSION");
 	char *endp;
 	int value;
-	unsigned int version = INDEX_FORMAT_DEFAULT;
+	unsigned int version = -1;
+
+	if (envversion) {
+		version = strtoul(envversion, &endp, 10);
+		if (*endp ||
+			version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
+			warning(_("GIT_INDEX_VERSION set, but the value is invalid.\n"
+				"Using version %i"), INDEX_FORMAT_DEFAULT);
+			version = INDEX_FORMAT_DEFAULT;
+		}
+	}
 
-	if (!envversion) {
-		if (!git_config_get_int("index.version", &value))
+	if (version == -1) {
+		if (!git_config_get_int("index.version", &value)) {
 			version = value;
-		if (version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
-			warning(_("index.version set, but the value is invalid.\n"
-				  "Using version %i"), INDEX_FORMAT_DEFAULT);
-			return INDEX_FORMAT_DEFAULT;
+			if (version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
+				warning(_("index.version set, but the value is invalid.\n"
+					"Using version %i"), INDEX_FORMAT_DEFAULT);
+				version = INDEX_FORMAT_DEFAULT;
+			}
 		}
-		return version;
 	}
 
-	version = strtoul(envversion, &endp, 10);
-	if (*endp ||
-	    version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
-		warning(_("GIT_INDEX_VERSION set, but the value is invalid.\n"
-			  "Using version %i"), INDEX_FORMAT_DEFAULT);
-		version = INDEX_FORMAT_DEFAULT;
+	if (version == -1) {
+		envversion = getenv("GIT_TEST_INDEX_VERSION");
+		if (envversion) {
+			version = strtoul(envversion, &endp, 10);
+			if (*endp ||
+				version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
+				warning(_("GIT_TEST_INDEX_VERSION set, but the value is invalid.\n"
+					"Using version %i"), INDEX_FORMAT_DEFAULT);
+				version = INDEX_FORMAT_DEFAULT;
+			}
+		}
 	}
+
+	if (version == -1)
+		version = INDEX_FORMAT_DEFAULT;
+
 	return version;
 }
 
diff --git a/t/README b/t/README
index 9028b47d92..f872638a78 100644
--- a/t/README
+++ b/t/README
@@ -315,10 +315,14 @@ packs on demand. This normally only happens when the object size is
 over 2GB. This variable forces the code path on any object larger than
 <n> bytes.
 
-GIT_TEST_OE_DELTA_SIZE=<n> exercises the uncomon pack-objects code
+GIT_TEST_OE_DELTA_SIZE=<n> exercises the uncommon pack-objects code
 path where deltas larger than this limit require extra memory
 allocation for bookkeeping.
 
+GIT_TEST_INDEX_VERSION=<n> exercises the index read/write code path
+for the index version specified.  Can be set to any valid version
+but the non-default version 4 is probably the most beneficial.
+
 Naming Tests
 ------------
 

base-commit: 1d4361b0f344188ab5eec6dcea01f61a3a3a1670
-- 
2.18.0.windows.1


             reply	other threads:[~2018-09-12 21:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 21:26 Ben Peart [this message]
2018-09-12 22:31 ` [PATCH v1] read-cache: add GIT_TEST_INDEX_VERSION support Thomas Gummerer
2018-09-13 14:07   ` Ben Peart
2018-09-13 21:56     ` Thomas Gummerer
2018-09-13 22:08       ` Junio C Hamano
2018-09-14 13:50         ` Ben Peart
2018-09-14 16:20           ` Junio C Hamano
2018-09-13 18:17 ` [PATCH v2] read-cache: update TEST_GIT_INDEX_VERSION support Ben Peart
2018-09-13 18:49 ` [PATCH v1] read-cache: add GIT_TEST_INDEX_VERSION support Ævar Arnfjörð Bjarmason
2018-09-13 20:59   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180912212544.33624-1-benpeart@microsoft.com \
    --to=benpeart@microsoft.com \
    --cc=Ben.Peart@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).