Class UnifiedDiffs

java.lang.Object
io.github.jbastgen.stemma.git.api.UnifiedDiffs

public final class UnifiedDiffs extends Object
Helpers shared by the backends to produce the FileDiff.hunks() format.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    The diff of a new text file: every line added.
    static String
    hunksOnly(String diffOutput)
    Reduces the output of a diff command to the hunks: drops everything before the first @@ line (the diff --git, index, --- and +++ header) and all \ No newline at end of file markers.
    static boolean
    looksBinary(byte[] content)
    Whether the content looks binary: a NUL byte within the first 8000 bytes, like git decides.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • hunksOnly

      public static String hunksOnly(String diffOutput)
      Reduces the output of a diff command to the hunks: drops everything before the first @@ line (the diff --git, index, --- and +++ header) and all \ No newline at end of file markers. Lines are joined by \n without a trailing newline.
    • allAdded

      public static String allAdded(List<String> lines)
      The diff of a new text file: every line added. An empty file has no hunks.
    • looksBinary

      public static boolean looksBinary(byte[] content)
      Whether the content looks binary: a NUL byte within the first 8000 bytes, like git decides.