@ -51,6 +51,7 @@ import java.util.Iterator;
import org.eclipse.jgit.junit.RepositoryTestCase ;
import org.eclipse.jgit.junit.RepositoryTestCase ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.RefUpdate ;
import org.eclipse.jgit.lib.RefUpdate ;
import org.eclipse.jgit.lib.RefUpdate.Result ;
import org.eclipse.jgit.lib.RefUpdate.Result ;
import org.eclipse.jgit.revwalk.RevCommit ;
import org.eclipse.jgit.revwalk.RevCommit ;
@ -94,9 +95,7 @@ public class StashListCommandTest extends RepositoryTestCase {
git . add ( ) . addFilepattern ( "file.txt" ) . call ( ) ;
git . add ( ) . addFilepattern ( "file.txt" ) . call ( ) ;
RevCommit commit = git . commit ( ) . setMessage ( "create file" ) . call ( ) ;
RevCommit commit = git . commit ( ) . setMessage ( "create file" ) . call ( ) ;
RefUpdate update = db . updateRef ( Constants . R_STASH ) ;
assertEquals ( Result . NEW , newStashUpdate ( commit ) . update ( ) ) ;
update . setNewObjectId ( commit ) ;
assertEquals ( Result . NEW , update . update ( ) ) ;
StashListCommand command = git . stashList ( ) ;
StashListCommand command = git . stashList ( ) ;
Collection < RevCommit > stashed = command . call ( ) ;
Collection < RevCommit > stashed = command . call ( ) ;
@ -117,13 +116,8 @@ public class StashListCommandTest extends RepositoryTestCase {
git . add ( ) . addFilepattern ( "file.txt" ) . call ( ) ;
git . add ( ) . addFilepattern ( "file.txt" ) . call ( ) ;
RevCommit commit2 = git . commit ( ) . setMessage ( "edit file" ) . call ( ) ;
RevCommit commit2 = git . commit ( ) . setMessage ( "edit file" ) . call ( ) ;
RefUpdate create = db . updateRef ( Constants . R_STASH ) ;
assertEquals ( Result . NEW , newStashUpdate ( commit1 ) . update ( ) ) ;
create . setNewObjectId ( commit1 ) ;
assertEquals ( Result . FAST_FORWARD , newStashUpdate ( commit2 ) . update ( ) ) ;
assertEquals ( Result . NEW , create . update ( ) ) ;
RefUpdate update = db . updateRef ( Constants . R_STASH ) ;
update . setNewObjectId ( commit2 ) ;
assertEquals ( Result . FAST_FORWARD , update . update ( ) ) ;
StashListCommand command = git . stashList ( ) ;
StashListCommand command = git . stashList ( ) ;
Collection < RevCommit > stashed = command . call ( ) ;
Collection < RevCommit > stashed = command . call ( ) ;
@ -133,4 +127,11 @@ public class StashListCommandTest extends RepositoryTestCase {
assertEquals ( commit2 , iter . next ( ) ) ;
assertEquals ( commit2 , iter . next ( ) ) ;
assertEquals ( commit1 , iter . next ( ) ) ;
assertEquals ( commit1 , iter . next ( ) ) ;
}
}
private RefUpdate newStashUpdate ( ObjectId newId ) throws Exception {
RefUpdate ru = db . updateRef ( Constants . R_STASH ) ;
ru . setNewObjectId ( newId ) ;
ru . setForceRefLog ( true ) ;
return ru ;
}
}
}