Skip to content
Permalink
Browse files
1008: GitCombinedDiffParser does not handle un-modified copied files
Reviewed-by: erikj
  • Loading branch information
edvbld committed May 3, 2021
1 parent 62e23e0 commit fb532a0707ba9ac53cfcc9be0cf63399c0880740
Showing with 5 additions and 4 deletions.
  1. +5 −4 vcs/src/main/java/org/openjdk/skara/vcs/git/GitCombinedDiffParser.java
@@ -50,10 +50,12 @@ public GitCombinedDiffParser(List<Hash> bases, Hash head, String delimiter) {

var filename = line.substring("diff --combined ".length());
var isRenamedWithRegardsToAllParents = headers.stream().allMatch(h -> h.status().isRenamed());
if (isRenamedWithRegardsToAllParents) {
// git diff -c does not give a "diff --combined" line, nor hunks, for a rename without modifications
var isCopiedWithRegardsToAllParents = headers.stream().allMatch(h -> h.status().isCopied());
if (isRenamedWithRegardsToAllParents || isCopiedWithRegardsToAllParents) {
// git diff -c does not give a "diff --combined" line, nor hunks, for a rename or copy without
// modifications.
if (headers.stream().noneMatch(h -> filename.equals(h.targetPath().toString()))) {
// This diff is for another file, this must have been a rename without modifications
// This diff is for another file, this must have been a rename or copy without modifications.
var result = new ArrayList<List<Hunk>>();
for (int i = 0; i < numParents; i++) {
result.add(List.of());
@@ -247,7 +249,6 @@ public GitCombinedDiffParser(List<Hash> bases, Hash head, String delimiter) {
int headerIndex = 0;
while (line != null && !line.equals(delimiter)) {
var headersForFile = headersForFiles.get(headerIndex);
var isRenamedWithRegardsToAllParents = headersForFile.stream().allMatch(h -> h.status().isRenamed());
var hunksPerParentForFile = parseSingleFileMultiParentDiff(reader, headersForFile);

if (hunksPerParentForFile.size() != numParents) {

1 comment on commit fb532a0

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on fb532a0 May 3, 2021

Please sign in to comment.