aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2009-09-11 12:33:05 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-02-03 19:58:20 -0800
commit29b8fa84e680ce090ed355afd6052c4be9137a0c (patch)
treefe7cb5afcd2272d1c7bdbd89e6d0167d92e34c12 /org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
parent329abf721214f60077c9b17cc2c4235bdeed2c4f (diff)
downloadjgit-29b8fa84e680ce090ed355afd6052c4be9137a0c.tar.gz
jgit-29b8fa84e680ce090ed355afd6052c4be9137a0c.zip
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>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
index db9f684fed..efea117388 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2008-2009, Google Inc.
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -74,8 +74,10 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
final String[] paths = { "a.", "a0b" };
final DirCacheEntry[] ents = new DirCacheEntry[paths.length];
- for (int i = 0; i < paths.length; i++)
+ for (int i = 0; i < paths.length; i++) {
ents[i] = new DirCacheEntry(paths[i]);
+ ents[i].setFileMode(FileMode.REGULAR_FILE);
+ }
final DirCacheBuilder b = dc.builder();
for (int i = 0; i < ents.length; i++)