Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does java-diff-utils support patch file with multiple files? #82

Closed
HuGanghui opened this issue Jun 12, 2020 · 3 comments
Closed

Does java-diff-utils support patch file with multiple files? #82

HuGanghui opened this issue Jun 12, 2020 · 3 comments

Comments

@HuGanghui
Copy link
Contributor

HuGanghui commented Jun 12, 2020

Describe the bug

When using diff command to compare two directories:

diff -u Origin/ Update/ > multiPatch.txt

we get multiPatch.txt:

diff -u Origin/Test1.java Update/Test1.java
--- Origin/Test1.java	2020-06-11 10:48:40.000000000 +0800
+++ Update/Test1.java	2020-06-11 10:48:40.000000000 +0800
@@ -1,7 +1,15 @@
-package checkstyle_demo.PatchSuppression.multiFile.Origin;
+package checkstyle_demo.PatchSuppression.multiFile.Update;
 
 public class Test1 {
     public void test1() {
 
     }
+
+    public void test2() {
+
+    }
+
+    public void test3() {
+
+    }
 }
diff -u Origin/Test2.java Update/Test2.java
--- Origin/Test2.java	2020-06-11 10:48:40.000000000 +0800
+++ Update/Test2.java	2020-06-11 10:48:41.000000000 +0800
@@ -1,7 +1,9 @@
-package checkstyle_demo.PatchSuppression.multiFile.Origin;
+package checkstyle_demo.PatchSuppression.multiFile.Update;
 
 public class Test2 {
     public void test1() {
         System.out.println();
+        System.out.println();
+        System.out.println();
     }
 }

To Reproduce
Steps to reproduce the behavior:

  1. Example data
  2. simple programm snippet
  3. See error

This need more than one file in every directories.
Origin dir:

cat Origin/test1.java

package checkstyle_demo.PatchSuppression.multiFile.Origin;

public class Test1 {
    public void test1() {

    }
}

cat Origin/test2.java

package checkstyle_demo.PatchSuppression.multiFile.Origin;

public class Test2 {
    public void test1() {
        System.out.println();
    }
}

Update dir:

Update/test1.java

package checkstyle_demo.PatchSuppression.multiFile.Update;

public class Test1 {
    public void test1() {

    }

    public void test2() {

    }

    public void test3() {

    }
}

Update/test2.java

package checkstyle_demo.PatchSuppression.multiFile.Update;

public class Test2 {
    public void test1() {
        System.out.println();
        System.out.println();
        System.out.println();
    }
}

run diff command

diff -u Origin/ Update/ > multiPatch.txt

cat multiPatch.txt

diff -u Origin/Test1.java Update/Test1.java
--- Origin/Test1.java	2020-06-11 10:48:40.000000000 +0800
+++ Update/Test1.java	2020-06-11 10:48:40.000000000 +0800
@@ -1,7 +1,15 @@
-package checkstyle_demo.PatchSuppression.multiFile.Origin;
+package checkstyle_demo.PatchSuppression.multiFile.Update;
 
 public class Test1 {
     public void test1() {
 
     }
+
+    public void test2() {
+
+    }
+
+    public void test3() {
+
+    }
 }
diff -u Origin/Test2.java Update/Test2.java
--- Origin/Test2.java	2020-06-11 10:48:40.000000000 +0800
+++ Update/Test2.java	2020-06-11 10:48:41.000000000 +0800
@@ -1,7 +1,9 @@
-package checkstyle_demo.PatchSuppression.multiFile.Origin;
+package checkstyle_demo.PatchSuppression.multiFile.Update;
 
 public class Test2 {
     public void test1() {
         System.out.println();
+        System.out.println();
+        System.out.println();
     }
 }

Expected behavior

And I want to know does java-diff-utils support patch file with multiple files? as far as I know, UnifiedDiffUtils.parseUnifiedDiff function can parse patch file with only one file.

System

  • Java version 1.8
  • Version
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils</artifactId>
<version>4.5</version>
@wumpz
Copy link
Collaborator

wumpz commented Jun 12, 2020

The new implementation is useable but not complete. It's in the unified diff package. This one supports multifile patches.

@wumpz
Copy link
Collaborator

wumpz commented Jun 12, 2020

To be honest, it worked for my needs. So I am happy to improve it with new features and pull requests are welcome as well.

@HuGanghui
Copy link
Contributor Author

HuGanghui commented Jun 13, 2020

@wumpz Thanks, I will try UnifiedDiffReader.parseUnifiedDiff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants