eoie: default to not writing EOIE section
authorJonathan Nieder <jrnieder@gmail.com>
Tue, 20 Nov 2018 06:11:47 +0000 (22:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 04:43:06 +0000 (13:43 +0900)
Since 3b1d9e04 (eoie: add End of Index Entry (EOIE) extension,
2018-10-10) Git defaults to writing the new EOIE section when writing
out an index file. Usually that is a good thing because it improves
threaded performance, but when a Git repository is shared with older
versions of Git, it produces a confusing warning:

$ git status
ignoring EOIE extension
HEAD detached at 371ed0defa
nothing to commit, working tree clean

Let's introduce the new index extension more gently. First we'll roll
out the new version of Git that understands it, and then once
sufficiently many users are using such a version, we can flip the
default to writing it by default.

Introduce a '[index] recordEndOfIndexEntries' configuration variable
to allow interested users to benefit from this index extension early.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/index.txt
read-cache.c
t/t1700-split-index.sh
index 4b94b6bedc03071109998ee7d27cf50c53e4194b..8e138aba7a460f1d5a628b43f684e28da9c3adce 100644 (file)
@@ -1,3 +1,10 @@
+index.recordEndOfIndexEntries::
+       Specifies whether the index file should include an "End Of Index
+       Entry" section. This reduces index load time on multiprocessor
+       machines but produces a message "ignoring EOIE extension" when
+       reading the index using Git versions before 2.20. Defaults to
+       'false'.
+
 index.threads::
        Specifies the number of threads to spawn when loading the index.
        This is meant to reduce index load time on multiprocessor machines.
index 4ca81286c00c57484a3567a56fa4d441725708da..1e9c772603070722899ee88f559c51283961e3d3 100644 (file)
@@ -2689,6 +2689,15 @@ void update_index_if_able(struct index_state *istate, struct lock_file *lockfile
                rollback_lock_file(lockfile);
 }
 
+static int record_eoie(void)
+{
+       int val;
+
+       if (!git_config_get_bool("index.recordendofindexentries", &val))
+               return val;
+       return 0;
+}
+
 /*
  * On success, `tempfile` is closed. If it is the temporary file
  * of a `struct lock_file`, we will therefore effectively perform
@@ -2936,7 +2945,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
         * read.  Write it out regardless of the strip_extensions parameter as we need it
         * when loading the shared index.
         */
-       if (offset) {
+       if (offset && record_eoie()) {
                struct strbuf sb = STRBUF_INIT;
 
                write_eoie_extension(&sb, &eoie_c, offset);
index 2ac47aa0e4a7164cd06037496832a1744990a774..0cbac64e28b26eebe2805c51748be99d647e039d 100755 (executable)
@@ -25,14 +25,17 @@ test_expect_success 'enable split index' '
        git update-index --split-index &&
        test-tool dump-split-index .git/index >actual &&
        indexversion=$(test-tool index-version <.git/index) &&
+
+       # NEEDSWORK: Stop hard-coding checksums.
        if test "$indexversion" = "4"
        then
-               own=3527df833c6c100d3d1d921a9a782d62a8be4b58
-               base=746f7ab2ed44fb839efdfbffcf399d0b113fb4cb
+               own=432ef4b63f32193984f339431fd50ca796493569
+               base=508851a7f0dfa8691e9f69c7f055865389012491
        else
-               own=5e9b60117ece18da410ddecc8b8d43766a0e4204
-               base=4370042739b31cd17a5c5cd6043a77c9a00df113
+               own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
+               base=39d890139ee5356c7ef572216cebcd27aa41f9df
        fi &&
+
        cat >expect <<-EOF &&
        own $own
        base $base