Skip to content

Commit f4ae3b5

Browse files
committed
Change to a simple boolean for Git-binary patch format
1 parent 694a164 commit f4ae3b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jgit/src/main/java/org/openrewrite/jgit/diff/DiffFormatter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class DiffFormatter implements AutoCloseable {
9999

100100
private RawTextComparator comparator = RawTextComparator.DEFAULT;
101101

102-
private PatchType patchType = PatchType.UNIFIED;
102+
private boolean binaryPatchFormat = false;
103103

104104
private int binaryFileThreshold = DEFAULT_BINARY_FILE_THRESHOLD;
105105

@@ -264,8 +264,8 @@ public void setBinaryFileThreshold(int threshold) {
264264
this.binaryFileThreshold = threshold;
265265
}
266266

267-
public void setPatchType(PatchType type) {
268-
this.patchType = type;
267+
public void setBinary(boolean binaryPatchFormat) {
268+
this.binaryPatchFormat = binaryPatchFormat;
269269
}
270270

271271
/**
@@ -723,7 +723,7 @@ private static byte[] writeGitLinkText(AbbreviatedObjectId id) {
723723
}
724724

725725
private String format(AbbreviatedObjectId id) {
726-
if (id.isComplete() && reader != null && patchType != PatchType.GIT_BINARY) {
726+
if (id.isComplete() && reader != null && binaryPatchFormat) {
727727
try {
728728
id = reader.abbreviate(id.toObjectId(), abbreviationLength);
729729
} catch (IOException cannotAbbreviate) {
@@ -1028,7 +1028,7 @@ private FormatResult createFormatResult(DiffEntry ent) throws IOException,
10281028
aRaw = new RawText(writeGitLinkText(ent.getOldId()));
10291029
bRaw = new RawText(writeGitLinkText(ent.getNewId()));
10301030
} else {
1031-
if (patchType == PatchType.GIT_BINARY) {
1031+
if (binaryPatchFormat) {
10321032
try {
10331033
aRaw = open(OLD, ent);
10341034
bRaw = open(NEW, ent);
@@ -1125,7 +1125,7 @@ private RawText open(DiffEntry.Side side, DiffEntry entry)
11251125

11261126
ObjectLoader ldr = LfsFactory.getInstance().applySmudgeFilter(repository,
11271127
source.open(side, entry), entry.getDiffAttribute());
1128-
if (patchType == PatchType.GIT_BINARY) {
1128+
if (binaryPatchFormat) {
11291129
return RawText.loadBinary(ldr, binaryFileThreshold);
11301130
} else {
11311131
return RawText.load(ldr, binaryFileThreshold);

0 commit comments

Comments
 (0)