Fix DirCache's skip over null byte padding when reading a DIRC file
commit06d7d84ad55da0b00f6d3f2e615f991f77a6b5a6
authorShawn O. Pearce <spearce@spearce.org>
Mon, 18 Aug 2008 16:35:33 +0000 (18 09:35 -0700)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 19 Aug 2008 20:33:56 +0000 (19 22:33 +0200)
tree413c5b238c659ff87fa45a09020a32d35dd6af40
parent6169f61a53d3ea3776e3af29c8c8197d4ecd6f09
Fix DirCache's skip over null byte padding when reading a DIRC file

Sometimes we hit EOFException while reading from a 'DIRC' file with
the new DirCache API.  This was caused by BufferedInputStream.skip
skipping only part of the range we asked it to skip if the range we
asked it to skip spanned over the end of the current buffer block.
Two skip requests are necessary in this case: one to force the stream
to skip to the end of the buffer, and another to skip over data in
the source stream before reading the next buffer block into memory.

NB.skipFully handles this by abstracting the necessary loop into
a utility function, much like NB.readFully handles the necessary
read loop to ensure we read a full block of data.

DirCacheEntry and DirCache both need to use this routine to skip
over the parts of the DIRC file they do not wish to read.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
org.spearce.jgit/src/org/spearce/jgit/util/NB.java