Source:
<code>public int compareTo(RepositoryTreeNode otherNode) { int typeDiff = this.myType.ordinal() - otherNode.getType().ordinal(); if (typeDiff != 0) return typeDiff; switch (myType) { case BRANCHES: case LOCAL: case REMOTETRACKING: case BRANCHHIERARCHY: return CommonUtils.STRING_ASCENDING_COMPARATOR.compare( myObject.toString(), otherNode.getObject().toString()); case REMOTES: case ADDITIONALREFS: case TAGS: case ERROR: case SUBMODULES: case STASH: case WORKINGDIR: return 0; case FETCH: case PUSH: case REMOTE: return CommonUtils.STRING_ASCENDING_COMPARATOR .compare((String) myObject, (String) otherNode.getObject()); case FILE: case FOLDER: return CommonUtils.STRING_ASCENDING_COMPARATOR .compare(((File) myObject).getName(), ((File) otherNode.getObject()).getName()); case STASHED_COMMIT: return ((StashedCommitNode) this).getIndex() - ((StashedCommitNode) otherNode).getIndex(); case TAG: int tagCompare = CommonUtils.REF_ASCENDING_COMPARATOR.compare( (Ref) myObject, (Ref) otherNode.getObject()); return ((TagNode) this).isSortAscending() ? tagCompare <START> : -tagCompare; <END> case ADDITIONALREF: case REF: return CommonUtils.REF_ASCENDING_COMPARATOR.compare((Ref) myObject, (Ref) otherNode.getObject()); case REPO: int nameCompare = CommonUtils.STRING_ASCENDING_COMPARATOR.compare( getDirectoryContainingRepo((Repository) myObject).getName(), getDirectoryContainingRepo( (Repository) otherNode.getObject()) .getName()); if (nameCompare != 0) return nameCompare; return CommonUtils.STRING_ASCENDING_COMPARATOR.compare( getDirectoryContainingRepo((Repository) myObject) .getParentFile().getPath(), getDirectoryContainingRepo( (Repository) otherNode.getObject()).getParentFile() .getPath()); } return 0; }</code><technical_language>mentioned in other change, is a bad practice negate result of compare(). contract, compare() return integer value. Negating minimum integer leads overflow. is a problem here, try hard avoid new static code analysis warnings, please call comparator times instead</technical_language>

Target:
public int compareTo(RepositoryTreeNode otherNode) { int typeDiff = this.myType.ordinal() - otherNode.getType().ordinal(); if (typeDiff != 0) return typeDiff; switch (myType) { case BRANCHES: case LOCAL: case REMOTETRACKING: case BRANCHHIERARCHY: return CommonUtils.STRING_ASCENDING_COMPARATOR.compare( myObject.toString(), otherNode.getObject().toString()); case REMOTES: case ADDITIONALREFS: case TAGS: case ERROR: case SUBMODULES: case STASH: case WORKINGDIR: return 0; case FETCH: case PUSH: case REMOTE: return CommonUtils.STRING_ASCENDING_COMPARATOR .compare((String) myObject, (String) otherNode.getObject()); case FILE: case FOLDER: return CommonUtils.STRING_ASCENDING_COMPARATOR .compare(((File) myObject).getName(), ((File) otherNode.getObject()).getName()); case STASHED_COMMIT: return ((StashedCommitNode) this).getIndex() - ((StashedCommitNode) otherNode).getIndex(); case TAG: case ADDITIONALREF: case REF: return CommonUtils.REF_ASCENDING_COMPARATOR.compare((Ref) myObject, (Ref) otherNode.getObject()); case REPO: int nameCompare = CommonUtils.STRING_ASCENDING_COMPARATOR.compare( getDirectoryContainingRepo((Repository) myObject).getName(), getDirectoryContainingRepo( (Repository) otherNode.getObject()) .getName()); if (nameCompare != 0) return nameCompare; return CommonUtils.STRING_ASCENDING_COMPARATOR.compare( getDirectoryContainingRepo((Repository) myObject) .getParentFile().getPath(), getDirectoryContainingRepo( (Repository) otherNode.getObject()).getParentFile() .getPath()); } return 0; }