@ -288,13 +288,14 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" ) . call ( ) ;
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" ) . call ( ) ;
assertEquals ( Status . OK , res . getStatus ( ) ) ;
assertEquals ( Status . OK , res . getStatus ( ) ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
rw . markStart ( rw . parseCommit ( db . resolve ( "refs/heads/topic" ) ) ) ;
rw . markStart ( rw . parseCommit ( db . resolve ( "refs/heads/topic" ) ) ) ;
assertDerivedFrom ( rw . next ( ) , e ) ;
assertDerivedFrom ( rw . next ( ) , e ) ;
assertDerivedFrom ( rw . next ( ) , d ) ;
assertDerivedFrom ( rw . next ( ) , d ) ;
assertDerivedFrom ( rw . next ( ) , c ) ;
assertDerivedFrom ( rw . next ( ) , c ) ;
assertEquals ( b , rw . next ( ) ) ;
assertEquals ( b , rw . next ( ) ) ;
assertEquals ( a , rw . next ( ) ) ;
assertEquals ( a , rw . next ( ) ) ;
}
List < ReflogEntry > headLog = db . getReflogReader ( Constants . HEAD )
List < ReflogEntry > headLog = db . getReflogReader ( Constants . HEAD )
. getReverseEntries ( ) ;
. getReverseEntries ( ) ;
@ -354,8 +355,6 @@ public class RebaseCommandTest extends RepositoryTestCase {
* /
* /
private void doTestRebasePreservingMerges ( boolean testConflict )
private void doTestRebasePreservingMerges ( boolean testConflict )
throws Exception {
throws Exception {
RevWalk rw = new RevWalk ( db ) ;
// create file1 on master
// create file1 on master
writeTrashFile ( FILE1 , FILE1 ) ;
writeTrashFile ( FILE1 , FILE1 ) ;
git . add ( ) . addFilepattern ( FILE1 ) . call ( ) ;
git . add ( ) . addFilepattern ( FILE1 ) . call ( ) ;
@ -409,7 +408,9 @@ public class RebaseCommandTest extends RepositoryTestCase {
f = git . commit ( ) . setMessage ( "commit f" ) . call ( ) ;
f = git . commit ( ) . setMessage ( "commit f" ) . call ( ) ;
} else {
} else {
assertEquals ( MergeStatus . MERGED , result . getMergeStatus ( ) ) ;
assertEquals ( MergeStatus . MERGED , result . getMergeStatus ( ) ) ;
f = rw . parseCommit ( result . getNewHead ( ) ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
f = rw . parseCommit ( result . getNewHead ( ) ) ;
}
}
}
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" )
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" )
@ -453,23 +454,25 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals ( "file2" , read ( "file2" ) ) ;
assertEquals ( "file2" , read ( "file2" ) ) ;
assertEquals ( "more change" , read ( "file3" ) ) ;
assertEquals ( "more change" , read ( "file3" ) ) ;
rw . markStart ( rw . parseCommit ( db . resolve ( "refs/heads/topic" ) ) ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
RevCommit newF = rw . next ( ) ;
rw . markStart ( rw . parseCommit ( db . resolve ( "refs/heads/topic" ) ) ) ;
assertDerivedFrom ( newF , f ) ;
RevCommit newF = rw . next ( ) ;
assertEquals ( 2 , newF . getParentCount ( ) ) ;
assertDerivedFrom ( newF , f ) ;
RevCommit newD = rw . next ( ) ;
assertEquals ( 2 , newF . getParentCount ( ) ) ;
assertDerivedFrom ( newD , d ) ;
RevCommit newD = rw . next ( ) ;
if ( testConflict )
assertDerivedFrom ( newD , d ) ;
assertEquals ( "d new" , readFile ( "conflict" , newD ) ) ;
if ( testConflict )
RevCommit newE = rw . next ( ) ;
assertEquals ( "d new" , readFile ( "conflict" , newD ) ) ;
assertDerivedFrom ( newE , e ) ;
RevCommit newE = rw . next ( ) ;
if ( testConflict )
assertDerivedFrom ( newE , e ) ;
assertEquals ( "e new" , readFile ( "conflict" , newE ) ) ;
if ( testConflict )
assertEquals ( newD , newF . getParent ( 0 ) ) ;
assertEquals ( "e new" , readFile ( "conflict" , newE ) ) ;
assertEquals ( newE , newF . getParent ( 1 ) ) ;
assertEquals ( newD , newF . getParent ( 0 ) ) ;
assertDerivedFrom ( rw . next ( ) , c ) ;
assertEquals ( newE , newF . getParent ( 1 ) ) ;
assertEquals ( b , rw . next ( ) ) ;
assertDerivedFrom ( rw . next ( ) , c ) ;
assertEquals ( a , rw . next ( ) ) ;
assertEquals ( b , rw . next ( ) ) ;
assertEquals ( a , rw . next ( ) ) ;
}
}
}
private String readFile ( String path , RevCommit commit ) throws IOException {
private String readFile ( String path , RevCommit commit ) throws IOException {
@ -517,88 +520,89 @@ public class RebaseCommandTest extends RepositoryTestCase {
* /
* /
private void doTestRebasePreservingMergesWithUnrelatedSide (
private void doTestRebasePreservingMergesWithUnrelatedSide (
boolean testConflict ) throws Exception {
boolean testConflict ) throws Exception {
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
rw . sort ( RevSort . TOPO ) ;
rw . sort ( RevSort . TOPO ) ;
writeTrashFile ( FILE1 , FILE1 ) ;
writeTrashFile ( FILE1 , FILE1 ) ;
git . add ( ) . addFilepattern ( FILE1 ) . call ( ) ;
git . add ( ) . addFilepattern ( FILE1 ) . call ( ) ;
RevCommit a = git . commit ( ) . setMessage ( "commit a" ) . call ( ) ;
RevCommit a = git . commit ( ) . setMessage ( "commit a" ) . call ( ) ;
writeTrashFile ( "file2" , "blah" ) ;
writeTrashFile ( "file2" , "blah" ) ;
git . add ( ) . addFilepattern ( "file2" ) . call ( ) ;
git . add ( ) . addFilepattern ( "file2" ) . call ( ) ;
RevCommit b = git . commit ( ) . setMessage ( "commit b" ) . call ( ) ;
RevCommit b = git . commit ( ) . setMessage ( "commit b" ) . call ( ) ;
// create a topic branch
createBranch ( b , "refs/heads/topic" ) ;
checkoutBranch ( "refs/heads/topic" ) ;
writeTrashFile ( "file3" , "more changess" ) ;
writeTrashFile ( FILE1 , "preparing conflict" ) ;
git . add ( ) . addFilepattern ( "file3" ) . addFilepattern ( FILE1 ) . call ( ) ;
RevCommit c = git . commit ( ) . setMessage ( "commit c" ) . call ( ) ;
createBranch ( a , "refs/heads/side" ) ;
checkoutBranch ( "refs/heads/side" ) ;
writeTrashFile ( "conflict" , "e" ) ;
writeTrashFile ( FILE1 , FILE1 + "\n" + "line 2" ) ;
git . add ( ) . addFilepattern ( "." ) . call ( ) ;
RevCommit e = git . commit ( ) . setMessage ( "commit e" ) . call ( ) ;
// switch back to topic and merge in side, creating d
// create a topic branch
checkoutBranch ( "refs/heads/topic" ) ;
createBranch ( b , "refs/heads/topic" ) ;
MergeResult result = git . merge ( ) . include ( e )
checkoutBranch ( "refs/heads/topic" ) ;
. setStrategy ( MergeStrategy . RESOLVE ) . call ( ) ;
assertEquals ( MergeStatus . CONFLICTING , result . getMergeStatus ( ) ) ;
writeTrashFile ( "file3" , "more changess" ) ;
assertEquals ( result . getConflicts ( ) . keySet ( ) ,
writeTrashFile ( FILE1 , "preparing conflict" ) ;
Collections . singleton ( FILE1 ) ) ;
git . add ( ) . addFilepattern ( "file3" ) . addFilepattern ( FILE1 ) . call ( ) ;
writeTrashFile ( FILE1 , "merge resolution" ) ;
RevCommit c = git . commit ( ) . setMessage ( "commit c" ) . call ( ) ;
git . add ( ) . addFilepattern ( FILE1 ) . call ( ) ;
RevCommit d = git . commit ( ) . setMessage ( "commit d" ) . call ( ) ;
RevCommit f = commitFile ( "file2" , "new content two" , "topic" ) ;
createBranch ( a , "refs/heads/side" ) ;
checkoutBranch ( "refs/heads/side" ) ;
writeTrashFile ( "conflict" , "e" ) ;
writeTrashFile ( FILE1 , FILE1 + "\n" + "line 2" ) ;
git . add ( ) . addFilepattern ( "." ) . call ( ) ;
RevCommit e = git . commit ( ) . setMessage ( "commit e" ) . call ( ) ;
checkoutBranch ( "refs/heads/master" ) ;
// switch back to topic and merge in side, creating d
writeTrashFile ( "fileg" , "fileg" ) ;
checkoutBranch ( "refs/heads/topic" ) ;
if ( testConflict )
MergeResult result = git . merge ( ) . include ( e )
writeTrashFile ( "conflict" , "g" ) ;
. setStrategy ( MergeStrategy . RESOLVE ) . call ( ) ;
git . add ( ) . addFilepattern ( "." ) . call ( ) ;
RevCommit g = git . commit ( ) . setMessage ( "commit g" ) . call ( ) ;
checkoutBranch ( "refs/heads/topic" ) ;
assertEquals ( MergeStatus . CONFLICTING , result . getMergeStatus ( ) ) ;
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" )
assertEquals ( result . getConflicts ( ) . keySet ( ) ,
. setPreserveMerges ( true ) . call ( ) ;
Collections . singleton ( FILE1 ) ) ;
if ( testConflict ) {
writeTrashFile ( FILE1 , "merge resolution" ) ;
assertEquals ( Status . STOPPED , res . getStatus ( ) ) ;
git . add ( ) . addFilepattern ( FILE1 ) . call ( ) ;
assertEquals ( Collections . singleton ( "conflict" ) , git . status ( ) . call ( )
RevCommit d = git . commit ( ) . setMessage ( "commit d" ) . call ( ) ;
. getConflicting ( ) ) ;
// resolve
RevCommit f = commitFile ( "file2" , "new content two" , "topic" ) ;
writeTrashFile ( "conflict" , "e" ) ;
git . add ( ) . addFilepattern ( "conflict" ) . call ( ) ;
checkoutBranch ( "refs/heads/master" ) ;
res = git . rebase ( ) . setOperation ( Operation . CONTINUE ) . call ( ) ;
writeTrashFile ( "fileg" , "fileg" ) ;
if ( testConflict )
writeTrashFile ( "conflict" , "g" ) ;
git . add ( ) . addFilepattern ( "." ) . call ( ) ;
RevCommit g = git . commit ( ) . setMessage ( "commit g" ) . call ( ) ;
checkoutBranch ( "refs/heads/topic" ) ;
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" )
. setPreserveMerges ( true ) . call ( ) ;
if ( testConflict ) {
assertEquals ( Status . STOPPED , res . getStatus ( ) ) ;
assertEquals ( Collections . singleton ( "conflict" ) , git . status ( ) . call ( )
. getConflicting ( ) ) ;
// resolve
writeTrashFile ( "conflict" , "e" ) ;
git . add ( ) . addFilepattern ( "conflict" ) . call ( ) ;
res = git . rebase ( ) . setOperation ( Operation . CONTINUE ) . call ( ) ;
}
assertEquals ( Status . OK , res . getStatus ( ) ) ;
assertEquals ( "merge resolution" , read ( FILE1 ) ) ;
assertEquals ( "new content two" , read ( "file2" ) ) ;
assertEquals ( "more changess" , read ( "file3" ) ) ;
assertEquals ( "fileg" , read ( "fileg" ) ) ;
rw . markStart ( rw . parseCommit ( db . resolve ( "refs/heads/topic" ) ) ) ;
RevCommit newF = rw . next ( ) ;
assertDerivedFrom ( newF , f ) ;
RevCommit newD = rw . next ( ) ;
assertDerivedFrom ( newD , d ) ;
assertEquals ( 2 , newD . getParentCount ( ) ) ;
RevCommit newC = rw . next ( ) ;
assertDerivedFrom ( newC , c ) ;
RevCommit newE = rw . next ( ) ;
assertEquals ( e , newE ) ;
assertEquals ( newC , newD . getParent ( 0 ) ) ;
assertEquals ( e , newD . getParent ( 1 ) ) ;
assertEquals ( g , rw . next ( ) ) ;
assertEquals ( b , rw . next ( ) ) ;
assertEquals ( a , rw . next ( ) ) ;
}
}
assertEquals ( Status . OK , res . getStatus ( ) ) ;
assertEquals ( "merge resolution" , read ( FILE1 ) ) ;
assertEquals ( "new content two" , read ( "file2" ) ) ;
assertEquals ( "more changess" , read ( "file3" ) ) ;
assertEquals ( "fileg" , read ( "fileg" ) ) ;
rw . markStart ( rw . parseCommit ( db . resolve ( "refs/heads/topic" ) ) ) ;
RevCommit newF = rw . next ( ) ;
assertDerivedFrom ( newF , f ) ;
RevCommit newD = rw . next ( ) ;
assertDerivedFrom ( newD , d ) ;
assertEquals ( 2 , newD . getParentCount ( ) ) ;
RevCommit newC = rw . next ( ) ;
assertDerivedFrom ( newC , c ) ;
RevCommit newE = rw . next ( ) ;
assertEquals ( e , newE ) ;
assertEquals ( newC , newD . getParent ( 0 ) ) ;
assertEquals ( e , newD . getParent ( 1 ) ) ;
assertEquals ( g , rw . next ( ) ) ;
assertEquals ( b , rw . next ( ) ) ;
assertEquals ( a , rw . next ( ) ) ;
}
}
@Test
@Test
@ -687,8 +691,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
checkFile ( theFile , "1master\n2\n3\ntopic\n" ) ;
checkFile ( theFile , "1master\n2\n3\ntopic\n" ) ;
// our old branch should be checked out again
// our old branch should be checked out again
assertEquals ( "refs/heads/topic" , db . getFullBranch ( ) ) ;
assertEquals ( "refs/heads/topic" , db . getFullBranch ( ) ) ;
assertEquals ( lastMasterChange , new RevWalk ( db ) . parseCommit (
try ( RevWalk rw = new RevWalk ( db ) ) {
db . resolve ( Constants . HEAD ) ) . getParent ( 0 ) ) ;
assertEquals ( lastMasterChange , rw . parseCommit (
db . resolve ( Constants . HEAD ) ) . getParent ( 0 ) ) ;
}
assertEquals ( origHead , db . readOrigHead ( ) ) ;
assertEquals ( origHead , db . readOrigHead ( ) ) ;
List < ReflogEntry > headLog = db . getReflogReader ( Constants . HEAD )
List < ReflogEntry > headLog = db . getReflogReader ( Constants . HEAD )
. getReverseEntries ( ) ;
. getReverseEntries ( ) ;
@ -737,8 +743,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" ) . call ( ) ;
RebaseResult res = git . rebase ( ) . setUpstream ( "refs/heads/master" ) . call ( ) ;
assertEquals ( Status . OK , res . getStatus ( ) ) ;
assertEquals ( Status . OK , res . getStatus ( ) ) ;
checkFile ( theFile , "1master\n2\n3\ntopic\n" ) ;
checkFile ( theFile , "1master\n2\n3\ntopic\n" ) ;
assertEquals ( lastMasterChange , new RevWalk ( db ) . parseCommit (
try ( RevWalk rw = new RevWalk ( db ) ) {
db . resolve ( Constants . HEAD ) ) . getParent ( 0 ) ) ;
assertEquals ( lastMasterChange , rw . parseCommit (
db . resolve ( Constants . HEAD ) ) . getParent ( 0 ) ) ;
}
List < ReflogEntry > headLog = db . getReflogReader ( Constants . HEAD )
List < ReflogEntry > headLog = db . getReflogReader ( Constants . HEAD )
. getReverseEntries ( ) ;
. getReverseEntries ( ) ;
@ -785,8 +793,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
// our old branch should be checked out again
// our old branch should be checked out again
assertEquals ( "refs/heads/file3" , db . getFullBranch ( ) ) ;
assertEquals ( "refs/heads/file3" , db . getFullBranch ( ) ) ;
assertEquals ( addFile2 , new RevWalk ( db ) . parseCommit (
try ( RevWalk rw = new RevWalk ( db ) ) {
db . resolve ( Constants . HEAD ) ) . getParent ( 0 ) ) ;
assertEquals ( addFile2 , rw . parseCommit (
db . resolve ( Constants . HEAD ) ) . getParent ( 0 ) ) ;
}
checkoutBranch ( "refs/heads/file2" ) ;
checkoutBranch ( "refs/heads/file2" ) ;
assertTrue ( new File ( db . getWorkTree ( ) , FILE1 ) . exists ( ) ) ;
assertTrue ( new File ( db . getWorkTree ( ) , FILE1 ) . exists ( ) ) ;
@ -846,9 +856,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals ( res . getStatus ( ) , Status . ABORTED ) ;
assertEquals ( res . getStatus ( ) , Status . ABORTED ) ;
assertEquals ( "refs/heads/topic" , db . getFullBranch ( ) ) ;
assertEquals ( "refs/heads/topic" , db . getFullBranch ( ) ) ;
checkFile ( FILE1 , "1topic" , "2" , "3" , "topic4" ) ;
checkFile ( FILE1 , "1topic" , "2" , "3" , "topic4" ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
assertEquals ( lastTopicCommit , rw
assertEquals ( lastTopicCommit ,
. parseCommit ( db . resolve ( Constants . HEAD ) ) ) ;
rw . parseCommit ( db . resolve ( Constants . HEAD ) ) ) ;
}
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
// rebase- dir in .git must be deleted
// rebase- dir in .git must be deleted
@ -909,9 +920,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals ( res . getStatus ( ) , Status . ABORTED ) ;
assertEquals ( res . getStatus ( ) , Status . ABORTED ) ;
assertEquals ( lastTopicCommit . getName ( ) , db . getFullBranch ( ) ) ;
assertEquals ( lastTopicCommit . getName ( ) , db . getFullBranch ( ) ) ;
checkFile ( FILE1 , "1topic" , "2" , "3" , "topic4" ) ;
checkFile ( FILE1 , "1topic" , "2" , "3" , "topic4" ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
assertEquals ( lastTopicCommit ,
assertEquals ( lastTopicCommit ,
rw . parseCommit ( db . resolve ( Constants . HEAD ) ) ) ;
rw . parseCommit ( db . resolve ( Constants . HEAD ) ) ) ;
}
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
// rebase- dir in .git must be deleted
// rebase- dir in .git must be deleted
@ -966,11 +978,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
RevCommit rc = rw . parseCommit ( headId ) ;
RevCommit rc = rw . parseCommit ( headId ) ;
RevCommit parent = rw . parseCommit ( rc . getParent ( 0 ) ) ;
RevCommit parent = rw . parseCommit ( rc . getParent ( 0 ) ) ;
assertEquals ( "change file1 in topic\n\nThis is conflicting" , parent
assertEquals ( "change file1 in topic\n\nThis is conflicting" , parent
. getFullMessage ( ) ) ;
. getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -1017,9 +1030,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
git . rebase ( ) . setOperation ( Operation . SKIP ) . call ( ) ;
git . rebase ( ) . setOperation ( Operation . SKIP ) . call ( ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
RevCommit rc = rw . parseCommit ( headId ) ;
RevCommit rc = rw . parseCommit ( headId ) ;
assertEquals ( "change file1 in master" , rc . getFullMessage ( ) ) ;
assertEquals ( "change file1 in master" , rc . getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -1308,10 +1322,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
git . rebase ( ) . setOperation ( Operation . SKIP ) . call ( ) ;
git . rebase ( ) . setOperation ( Operation . SKIP ) . call ( ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
RevCommit rc = rw . parseCommit ( headId ) ;
RevCommit rc = rw . parseCommit ( headId ) ;
RevCommit parent = rw . parseCommit ( rc . getParent ( 0 ) ) ;
RevCommit parent = rw . parseCommit ( rc . getParent ( 0 ) ) ;
assertEquals ( "A different commit message" , parent . getFullMessage ( ) ) ;
assertEquals ( "A different commit message" , parent . getFullMessage ( ) ) ;
}
}
}
private RevCommit writeFileAndCommit ( String fileName , String commitMessage ,
private RevCommit writeFileAndCommit ( String fileName , String commitMessage ,
@ -1420,9 +1435,10 @@ public class RebaseCommandTest extends RepositoryTestCase {
res = git . rebase ( ) . setOperation ( Operation . ABORT ) . call ( ) ;
res = git . rebase ( ) . setOperation ( Operation . ABORT ) . call ( ) ;
assertEquals ( res . getStatus ( ) , Status . ABORTED ) ;
assertEquals ( res . getStatus ( ) , Status . ABORTED ) ;
assertEquals ( "refs/heads/topic" , db . getFullBranch ( ) ) ;
assertEquals ( "refs/heads/topic" , db . getFullBranch ( ) ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
assertEquals ( conflicting , rw . parseCommit ( db . resolve ( Constants . HEAD ) ) ) ;
assertEquals ( conflicting , rw . parseCommit ( db . resolve ( Constants . HEAD ) ) ) ;
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
assertEquals ( RepositoryState . SAFE , db . getRepositoryState ( ) ) ;
}
// rebase- dir in .git must be deleted
// rebase- dir in .git must be deleted
assertFalse ( new File ( db . getDirectory ( ) , "rebase-merge" ) . exists ( ) ) ;
assertFalse ( new File ( db . getDirectory ( ) , "rebase-merge" ) . exists ( ) ) ;
@ -2286,14 +2302,15 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals ( RebaseResult . Status . OK , res2 . getStatus ( ) ) ;
assertEquals ( RebaseResult . Status . OK , res2 . getStatus ( ) ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevWalk rw = new RevWalk ( db ) ;
try ( RevWalk rw = new RevWalk ( db ) ) {
RevCommit rc = rw . parseCommit ( headId ) ;
RevCommit rc = rw . parseCommit ( headId ) ;
ObjectId head1Id = db . resolve ( Constants . HEAD + "~1" ) ;
ObjectId head1Id = db . resolve ( Constants . HEAD + "~1" ) ;
RevCommit rc1 = rw . parseCommit ( head1Id ) ;
RevCommit rc1 = rw . parseCommit ( head1Id ) ;
assertEquals ( rc . getFullMessage ( ) , c4 . getFullMessage ( ) ) ;
assertEquals ( rc . getFullMessage ( ) , c4 . getFullMessage ( ) ) ;
assertEquals ( rc1 . getFullMessage ( ) , c2 . getFullMessage ( ) ) ;
assertEquals ( rc1 . getFullMessage ( ) , c2 . getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -2643,15 +2660,16 @@ public class RebaseCommandTest extends RepositoryTestCase {
}
}
} ) . call ( ) ;
} ) . call ( ) ;
RevWalk walk = new RevWalk ( db ) ;
try ( RevWalk walk = new RevWalk ( db ) ) {
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
assertEquals ( headCommit . getFullMessage ( ) ,
assertEquals ( headCommit . getFullMessage ( ) ,
"update file2 on master\nnew line" ) ;
"update file2 on master\nnew line" ) ;
ObjectId head2Id = db . resolve ( Constants . HEAD + "^1" ) ;
ObjectId head2Id = db . resolve ( Constants . HEAD + "^1" ) ;
RevCommit head1Commit = walk . parseCommit ( head2Id ) ;
RevCommit head1Commit = walk . parseCommit ( head2Id ) ;
assertEquals ( "changed" , head1Commit . getFullMessage ( ) ) ;
assertEquals ( "changed" , head1Commit . getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -2722,17 +2740,18 @@ public class RebaseCommandTest extends RepositoryTestCase {
}
}
} ) . call ( ) ;
} ) . call ( ) ;
RevWalk walk = new RevWalk ( db ) ;
try ( RevWalk walk = new RevWalk ( db ) ) {
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
assertEquals ( headCommit . getFullMessage ( ) ,
assertEquals ( headCommit . getFullMessage ( ) ,
"update file2 on master\nnew line" ) ;
"update file2 on master\nnew line" ) ;
ObjectId head2Id = db . resolve ( Constants . HEAD + "^1" ) ;
ObjectId head2Id = db . resolve ( Constants . HEAD + "^1" ) ;
RevCommit head1Commit = walk . parseCommit ( head2Id ) ;
RevCommit head1Commit = walk . parseCommit ( head2Id ) ;
assertEquals (
assertEquals (
"Add file1\nnew line\nAdd file2\nnew line\nupdated file1 on master\nnew line" ,
"Add file1\nnew line\nAdd file2\nnew line\nupdated file1 on master\nnew line" ,
head1Commit . getFullMessage ( ) ) ;
head1Commit . getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -2804,15 +2823,16 @@ public class RebaseCommandTest extends RepositoryTestCase {
}
}
} ) . call ( ) ;
} ) . call ( ) ;
RevWalk walk = new RevWalk ( db ) ;
try ( RevWalk walk = new RevWalk ( db ) ) {
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
assertEquals ( headCommit . getFullMessage ( ) ,
assertEquals ( headCommit . getFullMessage ( ) ,
"update file2 on master\nnew line" ) ;
"update file2 on master\nnew line" ) ;
ObjectId head2Id = db . resolve ( Constants . HEAD + "^1" ) ;
ObjectId head2Id = db . resolve ( Constants . HEAD + "^1" ) ;
RevCommit head1Commit = walk . parseCommit ( head2Id ) ;
RevCommit head1Commit = walk . parseCommit ( head2Id ) ;
assertEquals ( "changed" , head1Commit . getFullMessage ( ) ) ;
assertEquals ( "changed" , head1Commit . getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -2855,16 +2875,17 @@ public class RebaseCommandTest extends RepositoryTestCase {
}
}
} ) . call ( ) ;
} ) . call ( ) ;
RevWalk walk = new RevWalk ( db ) ;
try ( RevWalk walk = new RevWalk ( db ) ) {
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
assertEquals ( "update file2 on master\nnew line" ,
assertEquals ( "update file2 on master\nnew line" ,
headCommit . getFullMessage ( ) ) ;
headCommit . getFullMessage ( ) ) ;
ObjectId head1Id = db . resolve ( Constants . HEAD + "^1" ) ;
ObjectId head1Id = db . resolve ( Constants . HEAD + "^1" ) ;
RevCommit head1Commit = walk . parseCommit ( head1Id ) ;
RevCommit head1Commit = walk . parseCommit ( head1Id ) ;
assertEquals ( "Add file2\nnew line" ,
assertEquals ( "Add file2\nnew line" ,
head1Commit . getFullMessage ( ) ) ;
head1Commit . getFullMessage ( ) ) ;
}
}
}
@Test
@Test
@ -2903,11 +2924,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
}
}
} ) . call ( ) ;
} ) . call ( ) ;
RevWalk walk = new RevWalk ( db ) ;
try ( RevWalk walk = new RevWalk ( db ) ) {
ObjectId headId = db . resolve ( Constants . HEAD ) ;
ObjectId headId = db . resolve ( Constants . HEAD ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
RevCommit headCommit = walk . parseCommit ( headId ) ;
assertEquals ( "Add file2" ,
assertEquals ( "Add file2" ,
headCommit . getFullMessage ( ) ) ;
headCommit . getFullMessage ( ) ) ;
}
}
}
@Test ( expected = InvalidRebaseStepException . class )
@Test ( expected = InvalidRebaseStepException . class )