diff options
author | XinTong Wang <xintong@ca.ibm.com> | 2015-12-08 15:03:26 -0500 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-03-03 01:43:02 +0100 |
commit | 770d36c8bafba2ad20686c161246a3a239cdf1d9 (patch) | |
tree | 321c15c91a7e17b61a05af454545e0ac44e4b4c3 /org.eclipse.jgit.test | |
parent | be8c525fa0664d429e23cbf070420cb84a4a1607 (diff) | |
download | jgit-770d36c8bafba2ad20686c161246a3a239cdf1d9.tar.gz jgit-770d36c8bafba2ad20686c161246a3a239cdf1d9.zip |
Fix apply patch which did not work with non-ascii characters
Bug: 483943
Change-Id: If28f64053d20ab1bee54245f223e952dc2fe392c
Signed-off-by: XinTong Wang <xintong@ca.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
14 files changed, 97 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII.patch new file mode 100644 index 0000000000..d6408c99ff --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII.patch @@ -0,0 +1,8 @@ +diff --git a/NonASCII b/NonASCII +index 2e65efe..7898192 100644 +--- a/NonASCII ++++ b/NonASCII +@@ -1 +1 @@ +-あ +\ No newline at end of file ++あ diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2.patch new file mode 100644 index 0000000000..cea6cfd156 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2.patch @@ -0,0 +1,9 @@ +diff --git a/NonASCII2 b/NonASCII2 +index 2e65efe..7898192 100644 +--- a/NonASCII2 ++++ b/NonASCII2 +@@ -1 +1 @@ +-你好, 世界! +\ No newline at end of file ++再见 +\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2_PostImage new file mode 100644 index 0000000000..5c8e34dbdb --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2_PostImage @@ -0,0 +1 @@ +再见
\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2_PreImage new file mode 100644 index 0000000000..43696610a6 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII2_PreImage @@ -0,0 +1 @@ +你好, 世界!
\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd.patch new file mode 100644 index 0000000000..de31a9eee3 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd.patch @@ -0,0 +1,7 @@ +diff --git a/NonASCIIAdd b/NonASCIIAdd +index 2e65efe..7898192 100644 +--- a/NonASCIIAdd ++++ b/NonASCIIAdd +@@ -0,0 +1 @@ ++あ +\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd2.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd2.patch new file mode 100644 index 0000000000..5b41e9c26a --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd2.patch @@ -0,0 +1,8 @@ +diff --git a/NonASCIIAdd2 b/NonASCIIAdd2 +new file mode 100644 +index 2e65efe..7898192 100644 +--- /dev/null ++++ b/NonASCIIAdd2 +@@ -0,0 +1 @@ ++あ +\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd2_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd2_PostImage new file mode 100644 index 0000000000..0575c798f0 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd2_PostImage @@ -0,0 +1 @@ +あ
\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd_PostImage new file mode 100644 index 0000000000..0575c798f0 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd_PostImage @@ -0,0 +1 @@ +あ
\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd_PreImage new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIAdd_PreImage diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIDel.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIDel.patch new file mode 100644 index 0000000000..80e8f82cce --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIDel.patch @@ -0,0 +1,9 @@ +diff --git a/NonASCIIDel b/NonASCIIDel +deleted file mode 100644 +new file mode 100644 +index 2e65efe..7898192 100644 +--- a/NonASCIIDel ++++ /dev/null +@@ -1 +0,0 @@ +-あ +\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIDel_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIDel_PreImage new file mode 100644 index 0000000000..0575c798f0 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCIIDel_PreImage @@ -0,0 +1 @@ +あ
\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII_PostImage new file mode 100644 index 0000000000..f2435a2989 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII_PostImage @@ -0,0 +1 @@ +あ diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII_PreImage new file mode 100644 index 0000000000..0575c798f0 --- /dev/null +++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/NonASCII_PreImage @@ -0,0 +1 @@ +あ
\ No newline at end of file diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java index d842046bb7..239c844c33 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java @@ -186,6 +186,55 @@ public class ApplyCommandTest extends RepositoryTestCase { b.getString(0, b.size(), false)); } + @Test + public void testNonASCII() throws Exception { + ApplyResult result = init("NonASCII"); + assertEquals(1, result.getUpdatedFiles().size()); + assertEquals(new File(db.getWorkTree(), "NonASCII"), + result.getUpdatedFiles().get(0)); + checkFile(new File(db.getWorkTree(), "NonASCII"), + b.getString(0, b.size(), false)); + } + + @Test + public void testNonASCII2() throws Exception { + ApplyResult result = init("NonASCII2"); + assertEquals(1, result.getUpdatedFiles().size()); + assertEquals(new File(db.getWorkTree(), "NonASCII2"), + result.getUpdatedFiles().get(0)); + checkFile(new File(db.getWorkTree(), "NonASCII2"), + b.getString(0, b.size(), false)); + } + + @Test + public void testNonASCIIAdd() throws Exception { + ApplyResult result = init("NonASCIIAdd"); + assertEquals(1, result.getUpdatedFiles().size()); + assertEquals(new File(db.getWorkTree(), "NonASCIIAdd"), + result.getUpdatedFiles().get(0)); + checkFile(new File(db.getWorkTree(), "NonASCIIAdd"), + b.getString(0, b.size(), false)); + } + + @Test + public void testNonASCIIAdd2() throws Exception { + ApplyResult result = init("NonASCIIAdd2", false, true); + assertEquals(1, result.getUpdatedFiles().size()); + assertEquals(new File(db.getWorkTree(), "NonASCIIAdd2"), + result.getUpdatedFiles().get(0)); + checkFile(new File(db.getWorkTree(), "NonASCIIAdd2"), + b.getString(0, b.size(), false)); + } + + @Test + public void testNonASCIIDel() throws Exception { + ApplyResult result = init("NonASCIIDel", true, false); + assertEquals(1, result.getUpdatedFiles().size()); + assertEquals(new File(db.getWorkTree(), "NonASCIIDel"), + result.getUpdatedFiles().get(0)); + assertFalse(new File(db.getWorkTree(), "NonASCIIDel").exists()); + } + private static byte[] readFile(final String patchFile) throws IOException { final InputStream in = getTestResource(patchFile); if (in == null) { |