Don't allow DirCacheEntry with mode of 0
commit29b8fa84e680ce090ed355afd6052c4be9137a0c
authorShawn O. Pearce <spearce@spearce.org>
Fri, 11 Sep 2009 19:33:05 +0000 (11 12:33 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Thu, 4 Feb 2010 03:58:20 +0000 (3 19:58 -0800)
treefe7cb5afcd2272d1c7bdbd89e6d0167d92e34c12
parent329abf721214f60077c9b17cc2c4235bdeed2c4f
Don't allow DirCacheEntry with mode of 0

A 0 file mode in a DirCacheEntry is not a valid mode.  To C git
such a value indicates the record should not be present.  We already
were catching this bad state and exceptioning out when writing tree
objects to disk, but we did not fail when writing the dircache back
to disk.  This allowed JGit applications to create a dircache file
which C git would not like to read.

Instead of checking the mode during writes, we now check during
mutation.  This allows application bugs to be detected sooner and
closer to the cause site.  It also allows us to avoid checking most
of the records which we read in from disk, as we can assume these
are formatted correctly.

Some of our unit tests were not setting the FileMode on their test
entry, so they had to be updated to use REGULAR_FILE.

Change-Id: Ie412053c390b737c0ece57b8e063e4355ee32437
Originally: http://thread.gmane.org/gmane.comp.version-control.git/128214/focus=128213
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Adam W. Hawks <awhawks@writeme.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBasicTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java [moved from org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheEntryTest.java with 75% similarity]
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheFindTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheLargePathTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheTreeTest.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java