Skip to content

Commit

Permalink
Merge branch 'nd/doc-index-format'
Browse files Browse the repository at this point in the history
Update the index format documentation to mention the v4 format.

* 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
  • Loading branch information
gitster committed Mar 19, 2013
2 parents f944ec9 + 647d879 commit 865e99b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion Documentation/git-update-index.txt
Expand Up @@ -145,7 +145,15 @@ you will need to handle the situation manually.


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


-z:: -z::
Only meaningful with `--stdin` or `--index-info`; paths are Only meaningful with `--stdin` or `--index-info`; paths are
Expand Down
6 changes: 3 additions & 3 deletions Documentation/technical/index-format.txt
Expand Up @@ -12,7 +12,7 @@ Git index format
The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache") The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache")


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


32-bit number of index entries. 32-bit number of index entries.


Expand Down Expand Up @@ -93,8 +93,8 @@ Git index format
12-bit name length if the length is less than 0xFFF; otherwise 0xFFF 12-bit name length if the length is less than 0xFFF; otherwise 0xFFF
is stored in this field. is stored in this field.


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


1-bit reserved for future 1-bit reserved for future


Expand Down
2 changes: 1 addition & 1 deletion read-cache.c
Expand Up @@ -1260,7 +1260,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE)) if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
return error("bad signature"); return error("bad signature");
hdr_version = ntohl(hdr->hdr_version); hdr_version = ntohl(hdr->hdr_version);
if (hdr_version < 2 || 4 < hdr_version) if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
return error("bad index version %d", hdr_version); return error("bad index version %d", hdr_version);
git_SHA1_Init(&c); git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, size - 20); git_SHA1_Update(&c, hdr, size - 20);
Expand Down

0 comments on commit 865e99b

Please sign in to comment.