Support path names longer than 4095 bytes in DirCache
commit8367e9e90af47624d349dc91e30a677610c0655e
authorShawn O. Pearce <spearce@spearce.org>
Tue, 19 Aug 2008 22:51:54 +0000 (19 15:51 -0700)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Wed, 20 Aug 2008 21:02:07 +0000 (20 23:02 +0200)
tree613fadebf49b16dc401d0f629519ec0572307174
parentb25a0c70c11db1879c7bb90278ef35b33d69a079
Support path names longer than 4095 bytes in DirCache

C Git supports long paths within the index file by setting the
length portion of the flags field to 4095 (0xfff) and then it
does a simple C strlen() on the remaining part of the string
to locate the first null byte.

The trick works because every index record must have between
1 and 8 null bytes trailing the entry as padding.  C Git had
this rule to make it easy to pass the mmap'd name portion of
an entry directly to system calls, and it helped to ensure
all members were aligned properly in memory.

We now support infinite length paths (well, up to 2GB) by
using the same encoding strategy, however paths under the
4095 limit still perform better as they do not require a
single byte read loop and a growing/shrinking byte buffer.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheLargePathTest.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java