|
|
|
@ -310,6 +310,34 @@ public class AddCommandTest extends RepositoryTestCase {
|
|
|
|
|
assertEquals(0, dc.getEntry("sub/b.txt").getStage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testAddIgnoredFile() throws Exception { |
|
|
|
|
new File(db.getWorkDir(), "sub").mkdir(); |
|
|
|
|
File file = new File(db.getWorkDir(), "sub/a.txt"); |
|
|
|
|
file.createNewFile(); |
|
|
|
|
PrintWriter writer = new PrintWriter(file); |
|
|
|
|
writer.print("content"); |
|
|
|
|
writer.close(); |
|
|
|
|
|
|
|
|
|
File ignoreFile = new File(db.getWorkDir(), ".gitignore"); |
|
|
|
|
ignoreFile.createNewFile(); |
|
|
|
|
writer = new PrintWriter(ignoreFile); |
|
|
|
|
writer.print("sub/b.txt"); |
|
|
|
|
writer.close(); |
|
|
|
|
|
|
|
|
|
File file2 = new File(db.getWorkDir(), "sub/b.txt"); |
|
|
|
|
file2.createNewFile(); |
|
|
|
|
writer = new PrintWriter(file2); |
|
|
|
|
writer.print("content b"); |
|
|
|
|
writer.close(); |
|
|
|
|
|
|
|
|
|
Git git = new Git(db); |
|
|
|
|
DirCache dc = git.add().addFilepattern("sub").call(); |
|
|
|
|
assertEquals("sub/a.txt", dc.getEntry("sub/a.txt").getPathString()); |
|
|
|
|
assertNull(dc.getEntry("sub/b.txt")); |
|
|
|
|
assertNotNull(dc.getEntry("sub/a.txt").getObjectId()); |
|
|
|
|
assertEquals(0, dc.getEntry("sub/a.txt").getStage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private DirCacheEntry addEntryToBuilder(String path, File file, |
|
|
|
|
ObjectWriter ow, DirCacheBuilder builder, int stage) |
|
|
|
|
throws IOException { |
|
|
|
|