boolean (@Nullable String content) { if (content == null) return false; List<String> lines = LineTokenizer.tokenizeIntoList(content, false); final ListIterator<String> iterator = lines.listIterator(); DiffFormat currentFormat = null; while (iterator.hasNext()) { String line = iterator.next(); if (line.startsWith(CONTEXT_HUNK_PREFIX)) { currentFormat = DiffFormat.CONTEXT; } else if (currentFormat == DiffFormat.CONTEXT && ourContextBeforeHunkStartPattern.matcher(line).matches()) { break; } else if (line.startsWith(UNIFIED_BEFORE_HUNK_PREFIX) && currentFormat == null) { currentFormat = DiffFormat.UNIFIED; } else if (currentFormat == DiffFormat.UNIFIED && line.startsWith(UNIFIED_AFTER_HUNK_PREFIX)) break; } if (currentFormat == null) return false; // can't detect format // check that contains at least one chunk while (iterator.hasNext()) { String line = iterator.next(); if (currentFormat == DiffFormat.CONTEXT) { if (ourContextAfterHunkStartPattern.matcher(line).matches()) return true; } else { if (ourUnifiedHunkStartPattern.matcher(line).matches()) return true; } } return false; }