@ -79,16 +79,16 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = header ( name ) ;
final FileHeader fh = header ( name ) ;
assertEquals ( gitLine ( name ) . length ( ) , fh . parseGitFileName ( 0 ,
assertEquals ( gitLine ( name ) . length ( ) , fh . parseGitFileName ( 0 ,
fh . buf . length ) ) ;
fh . buf . length ) ) ;
assertEquals ( name , fh . getOldName ( ) ) ;
assertEquals ( name , fh . getOldPath ( ) ) ;
assertSame ( fh . getOldName ( ) , fh . getNewName ( ) ) ;
assertSame ( fh . getOldPath ( ) , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
public void testParseGitFileName_FailFooBar ( ) {
public void testParseGitFileName_FailFooBar ( ) {
final FileHeader fh = data ( "a/foo b/bar\n-" ) ;
final FileHeader fh = data ( "a/foo b/bar\n-" ) ;
assertTrue ( fh . parseGitFileName ( 0 , fh . buf . length ) > 0 ) ;
assertTrue ( fh . parseGitFileName ( 0 , fh . buf . length ) > 0 ) ;
assertNull ( fh . getOldName ( ) ) ;
assertNull ( fh . getOldPath ( ) ) ;
assertNull ( fh . getNewName ( ) ) ;
assertNull ( fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
@ -97,8 +97,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = header ( name ) ;
final FileHeader fh = header ( name ) ;
assertEquals ( gitLine ( name ) . length ( ) , fh . parseGitFileName ( 0 ,
assertEquals ( gitLine ( name ) . length ( ) , fh . parseGitFileName ( 0 ,
fh . buf . length ) ) ;
fh . buf . length ) ) ;
assertEquals ( name , fh . getOldName ( ) ) ;
assertEquals ( name , fh . getOldPath ( ) ) ;
assertSame ( fh . getOldName ( ) , fh . getNewName ( ) ) ;
assertSame ( fh . getOldPath ( ) , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
@ -108,8 +108,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = dqHeader ( dqName ) ;
final FileHeader fh = dqHeader ( dqName ) ;
assertEquals ( dqGitLine ( dqName ) . length ( ) , fh . parseGitFileName ( 0 ,
assertEquals ( dqGitLine ( dqName ) . length ( ) , fh . parseGitFileName ( 0 ,
fh . buf . length ) ) ;
fh . buf . length ) ) ;
assertEquals ( name , fh . getOldName ( ) ) ;
assertEquals ( name , fh . getOldPath ( ) ) ;
assertSame ( fh . getOldName ( ) , fh . getNewName ( ) ) ;
assertSame ( fh . getOldPath ( ) , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
@ -119,8 +119,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = dqHeader ( dqName ) ;
final FileHeader fh = dqHeader ( dqName ) ;
assertEquals ( dqGitLine ( dqName ) . length ( ) , fh . parseGitFileName ( 0 ,
assertEquals ( dqGitLine ( dqName ) . length ( ) , fh . parseGitFileName ( 0 ,
fh . buf . length ) ) ;
fh . buf . length ) ) ;
assertEquals ( name , fh . getOldName ( ) ) ;
assertEquals ( name , fh . getOldPath ( ) ) ;
assertSame ( fh . getOldName ( ) , fh . getNewName ( ) ) ;
assertSame ( fh . getOldPath ( ) , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
@ -129,8 +129,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = header ( name ) ;
final FileHeader fh = header ( name ) ;
assertEquals ( gitLine ( name ) . length ( ) , fh . parseGitFileName ( 0 ,
assertEquals ( gitLine ( name ) . length ( ) , fh . parseGitFileName ( 0 ,
fh . buf . length ) ) ;
fh . buf . length ) ) ;
assertEquals ( name , fh . getOldName ( ) ) ;
assertEquals ( name , fh . getOldPath ( ) ) ;
assertSame ( fh . getOldName ( ) , fh . getNewName ( ) ) ;
assertSame ( fh . getOldPath ( ) , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
@ -139,8 +139,8 @@ public class FileHeaderTest extends TestCase {
final String header = "project-v-1.0/" + name + " mydev/" + name + "\n" ;
final String header = "project-v-1.0/" + name + " mydev/" + name + "\n" ;
final FileHeader fh = data ( header + "-" ) ;
final FileHeader fh = data ( header + "-" ) ;
assertEquals ( header . length ( ) , fh . parseGitFileName ( 0 , fh . buf . length ) ) ;
assertEquals ( header . length ( ) , fh . parseGitFileName ( 0 , fh . buf . length ) ) ;
assertEquals ( name , fh . getOldName ( ) ) ;
assertEquals ( name , fh . getOldPath ( ) ) ;
assertSame ( fh . getOldName ( ) , fh . getNewName ( ) ) ;
assertSame ( fh . getOldPath ( ) , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
}
}
@ -153,9 +153,9 @@ public class FileHeaderTest extends TestCase {
+ "@@ -0,0 +1 @@\n" + "+a\n" ) ;
+ "@@ -0,0 +1 @@\n" + "+a\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "/dev/null" , fh . getOldName ( ) ) ;
assertEquals ( "/dev/null" , fh . getOldPath ( ) ) ;
assertSame ( DiffEntry . DEV_NULL , fh . getOldName ( ) ) ;
assertSame ( DiffEntry . DEV_NULL , fh . getOldPath ( ) ) ;
assertEquals ( "\u00c5ngstr\u00f6m" , fh . getNewName ( ) ) ;
assertEquals ( "\u00c5ngstr\u00f6m" , fh . getNewPath ( ) ) ;
assertSame ( FileHeader . ChangeType . ADD , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . ChangeType . ADD , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
@ -178,9 +178,9 @@ public class FileHeaderTest extends TestCase {
+ "@@ -1 +0,0 @@\n" + "-a\n" ) ;
+ "@@ -1 +0,0 @@\n" + "-a\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "\u00c5ngstr\u00f6m" , fh . getOldName ( ) ) ;
assertEquals ( "\u00c5ngstr\u00f6m" , fh . getOldPath ( ) ) ;
assertEquals ( "/dev/null" , fh . getNewName ( ) ) ;
assertEquals ( "/dev/null" , fh . getNewPath ( ) ) ;
assertSame ( DiffEntry . DEV_NULL , fh . getNewName ( ) ) ;
assertSame ( DiffEntry . DEV_NULL , fh . getNewPath ( ) ) ;
assertSame ( FileHeader . ChangeType . DELETE , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . ChangeType . DELETE , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
@ -198,8 +198,8 @@ public class FileHeaderTest extends TestCase {
final FileHeader fh = data ( "diff --git a/a b b/a b\n"
final FileHeader fh = data ( "diff --git a/a b b/a b\n"
+ "old mode 100644\n" + "new mode 100755\n" ) ;
+ "old mode 100644\n" + "new mode 100755\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "a b" , fh . getOldName ( ) ) ;
assertEquals ( "a b" , fh . getOldPath ( ) ) ;
assertEquals ( "a b" , fh . getNewName ( ) ) ;
assertEquals ( "a b" , fh . getNewPath ( ) ) ;
assertSame ( FileHeader . ChangeType . MODIFY , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . ChangeType . MODIFY , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
@ -220,14 +220,14 @@ public class FileHeaderTest extends TestCase {
+ "rename to \" c/\\303\\205ngstr\\303\\266m\"\n" ) ;
+ "rename to \" c/\\303\\205ngstr\\303\\266m\"\n" ) ;
int ptr = fh . parseGitFileName ( 0 , fh . buf . length ) ;
int ptr = fh . parseGitFileName ( 0 , fh . buf . length ) ;
assertTrue ( ptr > 0 ) ;
assertTrue ( ptr > 0 ) ;
assertNull ( fh . getOldName ( ) ) ; // can't parse names on a rename
assertNull ( fh . getOldPath ( ) ) ; // can't parse names on a rename
assertNull ( fh . getNewName ( ) ) ;
assertNull ( fh . getNewPath ( ) ) ;
ptr = fh . parseGitHeaders ( ptr , fh . buf . length ) ;
ptr = fh . parseGitHeaders ( ptr , fh . buf . length ) ;
assertTrue ( ptr > 0 ) ;
assertTrue ( ptr > 0 ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( " c/\u00c5ngstr\u00f6m" , fh . getNewName ( ) ) ;
assertEquals ( " c/\u00c5ngstr\u00f6m" , fh . getNewPath ( ) ) ;
assertSame ( FileHeader . ChangeType . RENAME , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . ChangeType . RENAME , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
@ -249,14 +249,14 @@ public class FileHeaderTest extends TestCase {
+ "rename new \" c/\\303\\205ngstr\\303\\266m\"\n" ) ;
+ "rename new \" c/\\303\\205ngstr\\303\\266m\"\n" ) ;
int ptr = fh . parseGitFileName ( 0 , fh . buf . length ) ;
int ptr = fh . parseGitFileName ( 0 , fh . buf . length ) ;
assertTrue ( ptr > 0 ) ;
assertTrue ( ptr > 0 ) ;
assertNull ( fh . getOldName ( ) ) ; // can't parse names on a rename
assertNull ( fh . getOldPath ( ) ) ; // can't parse names on a rename
assertNull ( fh . getNewName ( ) ) ;
assertNull ( fh . getNewPath ( ) ) ;
ptr = fh . parseGitHeaders ( ptr , fh . buf . length ) ;
ptr = fh . parseGitHeaders ( ptr , fh . buf . length ) ;
assertTrue ( ptr > 0 ) ;
assertTrue ( ptr > 0 ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( " c/\u00c5ngstr\u00f6m" , fh . getNewName ( ) ) ;
assertEquals ( " c/\u00c5ngstr\u00f6m" , fh . getNewPath ( ) ) ;
assertSame ( FileHeader . ChangeType . RENAME , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . ChangeType . RENAME , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
@ -278,14 +278,14 @@ public class FileHeaderTest extends TestCase {
+ "copy to \" c/\\303\\205ngstr\\303\\266m\"\n" ) ;
+ "copy to \" c/\\303\\205ngstr\\303\\266m\"\n" ) ;
int ptr = fh . parseGitFileName ( 0 , fh . buf . length ) ;
int ptr = fh . parseGitFileName ( 0 , fh . buf . length ) ;
assertTrue ( ptr > 0 ) ;
assertTrue ( ptr > 0 ) ;
assertNull ( fh . getOldName ( ) ) ; // can't parse names on a copy
assertNull ( fh . getOldPath ( ) ) ; // can't parse names on a copy
assertNull ( fh . getNewName ( ) ) ;
assertNull ( fh . getNewPath ( ) ) ;
ptr = fh . parseGitHeaders ( ptr , fh . buf . length ) ;
ptr = fh . parseGitHeaders ( ptr , fh . buf . length ) ;
assertTrue ( ptr > 0 ) ;
assertTrue ( ptr > 0 ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( " c/\u00c5ngstr\u00f6m" , fh . getNewName ( ) ) ;
assertEquals ( " c/\u00c5ngstr\u00f6m" , fh . getNewPath ( ) ) ;
assertSame ( FileHeader . ChangeType . COPY , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . ChangeType . COPY , fh . getChangeType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
assertSame ( FileHeader . PatchType . UNIFIED , fh . getPatchType ( ) ) ;
@ -307,8 +307,8 @@ public class FileHeaderTest extends TestCase {
+ ".." + nid + " 100644\n" + "--- a/a\n" + "+++ b/a\n" ) ;
+ ".." + nid + " 100644\n" + "--- a/a\n" + "+++ b/a\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( "a" , fh . getNewName ( ) ) ;
assertEquals ( "a" , fh . getNewPath ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getOldMode ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getOldMode ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getNewMode ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getNewMode ( ) ) ;
@ -331,8 +331,8 @@ public class FileHeaderTest extends TestCase {
+ ".." + nid + "\n" + "--- a/a\n" + "+++ b/a\n" ) ;
+ ".." + nid + "\n" + "--- a/a\n" + "+++ b/a\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( "a" , fh . getNewName ( ) ) ;
assertEquals ( "a" , fh . getNewPath ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertFalse ( fh . hasMetaDataChanges ( ) ) ;
assertNull ( fh . getOldMode ( ) ) ;
assertNull ( fh . getOldMode ( ) ) ;
@ -357,8 +357,8 @@ public class FileHeaderTest extends TestCase {
+ " 100644\n" + "--- a/a\n" + "+++ b/a\n" ) ;
+ " 100644\n" + "--- a/a\n" + "+++ b/a\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( "a" , fh . getNewName ( ) ) ;
assertEquals ( "a" , fh . getNewPath ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getOldMode ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getOldMode ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getNewMode ( ) ) ;
assertSame ( FileMode . REGULAR_FILE , fh . getNewMode ( ) ) ;
@ -386,8 +386,8 @@ public class FileHeaderTest extends TestCase {
+ "\n" + "--- a/a\n" + "+++ b/a\n" ) ;
+ "\n" + "--- a/a\n" + "+++ b/a\n" ) ;
assertParse ( fh ) ;
assertParse ( fh ) ;
assertEquals ( "a" , fh . getOldName ( ) ) ;
assertEquals ( "a" , fh . getOldPath ( ) ) ;
assertEquals ( "a" , fh . getNewName ( ) ) ;
assertEquals ( "a" , fh . getNewPath ( ) ) ;
assertNull ( fh . getOldMode ( ) ) ;
assertNull ( fh . getOldMode ( ) ) ;
assertNull ( fh . getNewMode ( ) ) ;
assertNull ( fh . getNewMode ( ) ) ;