@ -44,7 +44,9 @@
package org.eclipse.jgit.api ;
package org.eclipse.jgit.api ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertTrue ;
import static org.junit.Assert.fail ;
import static org.junit.Assert.fail ;
import java.io.File ;
import java.io.File ;
@ -61,6 +63,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode ;
import org.eclipse.jgit.lib.FileMode ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectInserter ;
import org.eclipse.jgit.lib.ObjectInserter ;
import org.eclipse.jgit.lib.Repository ;
import org.eclipse.jgit.lib.RepositoryTestCase ;
import org.eclipse.jgit.lib.RepositoryTestCase ;
import org.eclipse.jgit.lib.StoredConfig ;
import org.eclipse.jgit.lib.StoredConfig ;
import org.eclipse.jgit.revwalk.RevCommit ;
import org.eclipse.jgit.revwalk.RevCommit ;
@ -684,6 +687,40 @@ public class AddCommandTest extends RepositoryTestCase {
assertEquals ( FileMode . EXECUTABLE_FILE , walk . getFileMode ( 0 ) ) ;
assertEquals ( FileMode . EXECUTABLE_FILE , walk . getFileMode ( 0 ) ) ;
}
}
@Test
public void testSubmoduleDeleteNotStagedWithUpdate ( ) throws Exception {
Git git = new Git ( db ) ;
writeTrashFile ( "file.txt" , "content" ) ;
git . add ( ) . addFilepattern ( "file.txt" ) . call ( ) ;
assertNotNull ( git . commit ( ) . setMessage ( "create file" ) . call ( ) ) ;
SubmoduleAddCommand command = new SubmoduleAddCommand ( db ) ;
String path = "sub" ;
command . setPath ( path ) ;
String uri = db . getDirectory ( ) . toURI ( ) . toString ( ) ;
command . setURI ( uri ) ;
Repository repo = command . call ( ) ;
assertNotNull ( repo ) ;
assertNotNull ( git . commit ( ) . setMessage ( "add submodule" ) . call ( ) ) ;
assertTrue ( git . status ( ) . call ( ) . isClean ( ) ) ;
FileUtils . delete ( repo . getWorkTree ( ) , FileUtils . RECURSIVE ) ;
FileUtils . mkdir ( new File ( db . getWorkTree ( ) , path ) , false ) ;
assertNotNull ( git . add ( ) . addFilepattern ( "." ) . setUpdate ( true ) . call ( ) ) ;
Status status = git . status ( ) . call ( ) ;
assertFalse ( status . isClean ( ) ) ;
assertTrue ( status . getAdded ( ) . isEmpty ( ) ) ;
assertTrue ( status . getChanged ( ) . isEmpty ( ) ) ;
assertTrue ( status . getRemoved ( ) . isEmpty ( ) ) ;
assertTrue ( status . getUntracked ( ) . isEmpty ( ) ) ;
assertTrue ( status . getModified ( ) . isEmpty ( ) ) ;
assertEquals ( 1 , status . getMissing ( ) . size ( ) ) ;
assertEquals ( path , status . getMissing ( ) . iterator ( ) . next ( ) ) ;
}
private DirCacheEntry addEntryToBuilder ( String path , File file ,
private DirCacheEntry addEntryToBuilder ( String path , File file ,
ObjectInserter newObjectInserter , DirCacheBuilder builder , int stage )
ObjectInserter newObjectInserter , DirCacheBuilder builder , int stage )
throws IOException {
throws IOException {