Merge branch 'nd/doc-index-format'
authorJunio C Hamano <gitster@pobox.com>
Tue, 19 Mar 2013 19:15:14 +0000 (12:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Mar 2013 19:15:14 +0000 (12:15 -0700)
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

1  2 
Documentation/git-update-index.txt
Documentation/technical/index-format.txt
read-cache.c
index 77a912d4ea0421ad604b3271a1e36975906d95f0,dd36d1328554840d2f90739db11ad33b4a677a7e..c92775829bd26d3d993600fd5bb104e527de59f4
@@@ -82,10 -82,10 +82,10 @@@ OPTION
        When these flags are specified, the object names recorded
        for the paths are not updated.  Instead, these options
        set and unset the "assume unchanged" bit for the
 -      paths.  When the "assume unchanged" bit is on, git stops
 +      paths.  When the "assume unchanged" bit is on, Git stops
        checking the working tree files for possible
        modifications, so you need to manually unset the bit to
 -      tell git when you change the working tree file. This is
 +      tell Git when you change the working tree file. This is
        sometimes helpful when working with a big project on a
        filesystem that has very slow lstat(2) system call
        (e.g. cifs).
@@@ -145,7 -145,15 +145,15 @@@ you will need to handle the situation m
  
  --index-version <n>::
        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::
        Only meaningful with `--stdin` or `--index-info`; paths are
@@@ -253,18 -261,18 +261,18 @@@ $ git ls-files -
  Using ``assume unchanged'' bit
  ------------------------------
  
 -Many operations in git depend on your filesystem to have an
 +Many operations in Git depend on your filesystem to have an
  efficient `lstat(2)` implementation, so that `st_mtime`
  information for working tree files can be cheaply checked to see
  if the file contents have changed from the version recorded in
  the index file.  Unfortunately, some filesystems have
  inefficient `lstat(2)`.  If your filesystem is one of them, you
  can set "assume unchanged" bit to paths you have not changed to
 -cause git not to do this check.  Note that setting this bit on a
 -path does not mean git will check the contents of the file to
 -see if it has changed -- it makes git to omit any checking and
 +cause Git not to do this check.  Note that setting this bit on a
 +path does not mean Git will check the contents of the file to
 +see if it has changed -- it makes Git to omit any checking and
  assume it has *not* changed.  When you make changes to working
 -tree files, you have to explicitly tell git about it by dropping
 +tree files, you have to explicitly tell Git about it by dropping
  "assume unchanged" bit, either before or after you modify them.
  
  In order to set "assume unchanged" bit, use `--assume-unchanged`
@@@ -274,7 -282,7 +282,7 @@@ have the "assume unchanged" bit set, us
  
  The command looks at `core.ignorestat` configuration variable.  When
  this is true, paths updated with `git update-index paths...` and
 -paths updated with other git commands that update both index and
 +paths updated with other Git commands that update both index and
  working tree (e.g. 'git apply --index', 'git checkout-index -u',
  and 'git read-tree -u') are automatically marked as "assume
  unchanged".  Note that "assume unchanged" bit is *not* set if
index 27c716b15f5de5103eb6afe4b23a5a5a84a1fd7f,dcd51b97d9a94c53acaf5efc66e23da089a08f6a..0810251f5a316de548d906bde65fba5af3507e4d
@@@ -1,7 -1,7 +1,7 @@@
 -GIT index format
 +Git index format
  ================
  
 -== The git index file has the following format
 +== The Git index file has the following format
  
    All binary numbers are in network byte order. Version 2 is described
    here unless stated otherwise.
@@@ -12,7 -12,7 +12,7 @@@
         The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache")
  
       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.
  
@@@ -21,9 -21,9 +21,9 @@@
     - Extensions
  
       Extensions are identified by signature. Optional extensions can
 -     be ignored if GIT does not understand them.
 +     be ignored if Git does not understand them.
  
 -     GIT currently supports cached tree and resolve undo extensions.
 +     Git currently supports cached tree and resolve undo extensions.
  
       4-byte extension signature. If the first byte is 'A'..'Z' the
       extension is optional and can be ignored.
@@@ -93,8 -93,8 +93,8 @@@
      12-bit name length if the length is less than 0xFFF; otherwise 0xFFF
      is stored in this field.
  
-   (Version 3) A 16-bit field, only applicable if the "extended flag"
-   above is 1, split into (high to low bits).
+   (Version 3 or later) A 16-bit field, only applicable if the
+   "extended flag" above is 1, split into (high to low bits).
  
      1-bit reserved for future
  
diff --combined read-cache.c
index 827ae55c508addf5c058872e554a3d914389e324,5cddbc325ff3f85c693f600836a08fac755846bb..670a06bc7996da83650d47a72685315f918e26b2
@@@ -197,25 -197,21 +197,25 @@@ static int ce_match_stat_basic(struct c
        }
        if (ce->ce_mtime.sec != (unsigned int)st->st_mtime)
                changed |= MTIME_CHANGED;
 -      if (trust_ctime && ce->ce_ctime.sec != (unsigned int)st->st_ctime)
 +      if (trust_ctime && check_stat &&
 +          ce->ce_ctime.sec != (unsigned int)st->st_ctime)
                changed |= CTIME_CHANGED;
  
  #ifdef USE_NSEC
 -      if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
 +      if (check_stat && ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
                changed |= MTIME_CHANGED;
 -      if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
 +      if (trust_ctime && check_stat &&
 +          ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
                changed |= CTIME_CHANGED;
  #endif
  
 -      if (ce->ce_uid != (unsigned int) st->st_uid ||
 -          ce->ce_gid != (unsigned int) st->st_gid)
 -              changed |= OWNER_CHANGED;
 -      if (ce->ce_ino != (unsigned int) st->st_ino)
 -              changed |= INODE_CHANGED;
 +      if (check_stat) {
 +              if (ce->ce_uid != (unsigned int) st->st_uid ||
 +                      ce->ce_gid != (unsigned int) st->st_gid)
 +                      changed |= OWNER_CHANGED;
 +              if (ce->ce_ino != (unsigned int) st->st_ino)
 +                      changed |= INODE_CHANGED;
 +      }
  
  #ifdef USE_STDEV
        /*
         * clients will have different views of what "device"
         * the filesystem is on
         */
 -      if (ce->ce_dev != (unsigned int) st->st_dev)
 -              changed |= INODE_CHANGED;
 +      if (check_stat && ce->ce_dev != (unsigned int) st->st_dev)
 +                      changed |= INODE_CHANGED;
  #endif
  
        if (ce->ce_size != (unsigned int) st->st_size)
@@@ -1260,7 -1256,7 +1260,7 @@@ static int verify_hdr(struct cache_head
        if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
                return error("bad signature");
        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);
        git_SHA1_Init(&c);
        git_SHA1_Update(&c, hdr, size - 20);