Skip to content

Commit d846550

Browse files
jrngitster
authored andcommitted
eoie: default to not writing EOIE section
Since 3b1d9e0 (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 371ed0d 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb75be6 commit d846550

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

Documentation/config/index.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
index.recordEndOfIndexEntries::
2+
Specifies whether the index file should include an "End Of Index
3+
Entry" section. This reduces index load time on multiprocessor
4+
machines but produces a message "ignoring EOIE extension" when
5+
reading the index using Git versions before 2.20. Defaults to
6+
'false'.
7+
18
index.threads::
29
Specifies the number of threads to spawn when loading the index.
310
This is meant to reduce index load time on multiprocessor machines.

read-cache.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,15 @@ void update_index_if_able(struct index_state *istate, struct lock_file *lockfile
26892689
rollback_lock_file(lockfile);
26902690
}
26912691

2692+
static int record_eoie(void)
2693+
{
2694+
int val;
2695+
2696+
if (!git_config_get_bool("index.recordendofindexentries", &val))
2697+
return val;
2698+
return 0;
2699+
}
2700+
26922701
/*
26932702
* On success, `tempfile` is closed. If it is the temporary file
26942703
* 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,
29362945
* read. Write it out regardless of the strip_extensions parameter as we need it
29372946
* when loading the shared index.
29382947
*/
2939-
if (offset) {
2948+
if (offset && record_eoie()) {
29402949
struct strbuf sb = STRBUF_INIT;
29412950

29422951
write_eoie_extension(&sb, &eoie_c, offset);

t/t1700-split-index.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ test_expect_success 'enable split index' '
2525
git update-index --split-index &&
2626
test-tool dump-split-index .git/index >actual &&
2727
indexversion=$(test-tool index-version <.git/index) &&
28+
29+
# NEEDSWORK: Stop hard-coding checksums.
2830
if test "$indexversion" = "4"
2931
then
30-
own=3527df833c6c100d3d1d921a9a782d62a8be4b58
31-
base=746f7ab2ed44fb839efdfbffcf399d0b113fb4cb
32+
own=432ef4b63f32193984f339431fd50ca796493569
33+
base=508851a7f0dfa8691e9f69c7f055865389012491
3234
else
33-
own=5e9b60117ece18da410ddecc8b8d43766a0e4204
34-
base=4370042739b31cd17a5c5cd6043a77c9a00df113
35+
own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
36+
base=39d890139ee5356c7ef572216cebcd27aa41f9df
3537
fi &&
38+
3639
cat >expect <<-EOF &&
3740
own $own
3841
base $base

0 commit comments

Comments
 (0)