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>