Skip to content

Commit a7b6ad5

Browse files
committed
Merge branch 'nd/doc-index-format' into maint-1.8.1
The v4 index format was not documented. * nd/doc-index-format: update-index: list supported idx versions and their features read-cache.c: use INDEX_FORMAT_{LB,UB} in verify_hdr() index-format.txt: mention of v4 is missing in some places
2 parents 8ddd9c1 + 647d879 commit a7b6ad5

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Documentation/git-update-index.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ you will need to handle the situation manually.
145145

146146
--index-version <n>::
147147
Write the resulting index out in the named on-disk format version.
148-
The current default version is 2.
148+
Supported versions are 2, 3 and 4. The current default version is 2
149+
or 3, depending on whether extra features are used, such as
150+
`git add -N`.
151+
+
152+
Version 4 performs a simple pathname compression that reduces index
153+
size by 30%-50% on large repositories, which results in faster load
154+
time. Version 4 is relatively young (first released in in 1.8.0 in
155+
October 2012). Other Git implementations such as JGit and libgit2
156+
may not support it yet.
149157

150158
-z::
151159
Only meaningful with `--stdin` or `--index-info`; paths are

Documentation/technical/index-format.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ GIT index format
1212
The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache")
1313

1414
4-byte version number:
15-
The current supported versions are 2 and 3.
15+
The current supported versions are 2, 3 and 4.
1616

1717
32-bit number of index entries.
1818

@@ -93,8 +93,8 @@ GIT index format
9393
12-bit name length if the length is less than 0xFFF; otherwise 0xFFF
9494
is stored in this field.
9595

96-
(Version 3) A 16-bit field, only applicable if the "extended flag"
97-
above is 1, split into (high to low bits).
96+
(Version 3 or later) A 16-bit field, only applicable if the
97+
"extended flag" above is 1, split into (high to low bits).
9898

9999
1-bit reserved for future
100100

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
12561256
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
12571257
return error("bad signature");
12581258
hdr_version = ntohl(hdr->hdr_version);
1259-
if (hdr_version < 2 || 4 < hdr_version)
1259+
if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
12601260
return error("bad index version %d", hdr_version);
12611261
git_SHA1_Init(&c);
12621262
git_SHA1_Update(&c, hdr, size - 20);

0 commit comments

Comments
 (0)