PatchScriptBuilder: Remove unnecessary else-clauses
Change-Id: Ia6fca30672cacbb9fd36e05fe1e36fb41b2492e6
This commit is contained in:
@@ -522,69 +522,67 @@ class PatchScriptBuilder {
|
|||||||
MimeUtil2.UNKNOWN_MIME_TYPE,
|
MimeUtil2.UNKNOWN_MIME_TYPE,
|
||||||
DisplayMethod.NONE,
|
DisplayMethod.NONE,
|
||||||
false);
|
false);
|
||||||
|
}
|
||||||
|
Text src =
|
||||||
|
isCommitMsg
|
||||||
|
? Text.forCommit(reader, within)
|
||||||
|
: Text.forMergeList(comparisonType, reader, within);
|
||||||
|
byte[] srcContent = src.getContent();
|
||||||
|
DisplayMethod displayMethod;
|
||||||
|
FileMode mode;
|
||||||
|
if (src == Text.EMPTY) {
|
||||||
|
mode = FileMode.MISSING;
|
||||||
|
displayMethod = DisplayMethod.NONE;
|
||||||
} else {
|
} else {
|
||||||
Text src =
|
mode = FileMode.REGULAR_FILE;
|
||||||
isCommitMsg
|
displayMethod = DisplayMethod.DIFF;
|
||||||
? Text.forCommit(reader, within)
|
|
||||||
: Text.forMergeList(comparisonType, reader, within);
|
|
||||||
byte[] srcContent = src.getContent();
|
|
||||||
DisplayMethod displayMethod;
|
|
||||||
FileMode mode;
|
|
||||||
if (src == Text.EMPTY) {
|
|
||||||
mode = FileMode.MISSING;
|
|
||||||
displayMethod = DisplayMethod.NONE;
|
|
||||||
} else {
|
|
||||||
mode = FileMode.REGULAR_FILE;
|
|
||||||
displayMethod = DisplayMethod.DIFF;
|
|
||||||
}
|
|
||||||
return createSide(
|
|
||||||
path,
|
|
||||||
within,
|
|
||||||
mode,
|
|
||||||
srcContent,
|
|
||||||
src,
|
|
||||||
MimeUtil2.UNKNOWN_MIME_TYPE,
|
|
||||||
displayMethod,
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
} else {
|
return createSide(
|
||||||
final TreeWalk tw = find(path, within);
|
path,
|
||||||
ObjectId id = tw != null ? tw.getObjectId(0) : ObjectId.zeroId();
|
within,
|
||||||
FileMode mode = tw != null ? tw.getFileMode(0) : FileMode.MISSING;
|
mode,
|
||||||
boolean reuse =
|
srcContent,
|
||||||
other != null
|
src,
|
||||||
&& other.id.equals(id)
|
MimeUtil2.UNKNOWN_MIME_TYPE,
|
||||||
&& (other.mode == mode || isBothFile(other.mode, mode));
|
displayMethod,
|
||||||
Text src = null;
|
false);
|
||||||
byte[] srcContent;
|
|
||||||
if (reuse) {
|
|
||||||
srcContent = other.srcContent;
|
|
||||||
|
|
||||||
} else if (mode.getObjectType() == Constants.OBJ_BLOB) {
|
|
||||||
srcContent = Text.asByteArray(db.open(id, Constants.OBJ_BLOB));
|
|
||||||
|
|
||||||
} else if (mode.getObjectType() == Constants.OBJ_COMMIT) {
|
|
||||||
String strContent = "Subproject commit " + ObjectId.toString(id);
|
|
||||||
srcContent = strContent.getBytes(UTF_8);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
srcContent = Text.NO_BYTES;
|
|
||||||
}
|
|
||||||
MimeType mimeType = MimeUtil2.UNKNOWN_MIME_TYPE;
|
|
||||||
DisplayMethod displayMethod = DisplayMethod.DIFF;
|
|
||||||
if (reuse) {
|
|
||||||
mimeType = other.mimeType;
|
|
||||||
displayMethod = other.displayMethod;
|
|
||||||
src = other.src;
|
|
||||||
|
|
||||||
} else if (srcContent.length > 0 && FileMode.SYMLINK != mode) {
|
|
||||||
mimeType = registry.getMimeType(path, srcContent);
|
|
||||||
if ("image".equals(mimeType.getMediaType()) && registry.isSafeInline(mimeType)) {
|
|
||||||
displayMethod = DisplayMethod.IMG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return createSide(path, id, mode, srcContent, src, mimeType, displayMethod, reuse);
|
|
||||||
}
|
}
|
||||||
|
final TreeWalk tw = find(path, within);
|
||||||
|
ObjectId id = tw != null ? tw.getObjectId(0) : ObjectId.zeroId();
|
||||||
|
FileMode mode = tw != null ? tw.getFileMode(0) : FileMode.MISSING;
|
||||||
|
boolean reuse =
|
||||||
|
other != null
|
||||||
|
&& other.id.equals(id)
|
||||||
|
&& (other.mode == mode || isBothFile(other.mode, mode));
|
||||||
|
Text src = null;
|
||||||
|
byte[] srcContent;
|
||||||
|
if (reuse) {
|
||||||
|
srcContent = other.srcContent;
|
||||||
|
|
||||||
|
} else if (mode.getObjectType() == Constants.OBJ_BLOB) {
|
||||||
|
srcContent = Text.asByteArray(db.open(id, Constants.OBJ_BLOB));
|
||||||
|
|
||||||
|
} else if (mode.getObjectType() == Constants.OBJ_COMMIT) {
|
||||||
|
String strContent = "Subproject commit " + ObjectId.toString(id);
|
||||||
|
srcContent = strContent.getBytes(UTF_8);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
srcContent = Text.NO_BYTES;
|
||||||
|
}
|
||||||
|
MimeType mimeType = MimeUtil2.UNKNOWN_MIME_TYPE;
|
||||||
|
DisplayMethod displayMethod = DisplayMethod.DIFF;
|
||||||
|
if (reuse) {
|
||||||
|
mimeType = other.mimeType;
|
||||||
|
displayMethod = other.displayMethod;
|
||||||
|
src = other.src;
|
||||||
|
|
||||||
|
} else if (srcContent.length > 0 && FileMode.SYMLINK != mode) {
|
||||||
|
mimeType = registry.getMimeType(path, srcContent);
|
||||||
|
if ("image".equals(mimeType.getMediaType()) && registry.isSafeInline(mimeType)) {
|
||||||
|
displayMethod = DisplayMethod.IMG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return createSide(path, id, mode, srcContent, src, mimeType, displayMethod, reuse);
|
||||||
} catch (IOException err) {
|
} catch (IOException err) {
|
||||||
throw new IOException("Cannot read " + within.name() + ":" + path, err);
|
throw new IOException("Cannot read " + within.name() + ":" + path, err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user