From e5f2114530046be50ef7d85cd595dbd37fc58e42 Mon Sep 17 00:00:00 2001 From: Arthur Daussy Date: Fri, 4 May 2018 15:18:46 +0200 Subject: [PATCH] [534365] Fix RecursiveModelMerger for "binary" git attributes Properly sets up the TreeWalk in indexModelMergedFiles so it can access Git attributes. Bug: 534365 Change-Id: Ib4dd97c995bfa79d180f0a661a64a6ab5675e8ad --- .../emf/compare/egit/internal/merge/RecursiveModelMerger.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.emf.compare.egit/src/org/eclipse/emf/compare/egit/internal/merge/RecursiveModelMerger.java b/plugins/org.eclipse.emf.compare.egit/src/org/eclipse/emf/compare/egit/internal/merge/RecursiveModelMerger.java index 5c28d7dec..76017d522 100644 --- a/plugins/org.eclipse.emf.compare.egit/src/org/eclipse/emf/compare/egit/internal/merge/RecursiveModelMerger.java +++ b/plugins/org.eclipse.emf.compare.egit/src/org/eclipse/emf/compare/egit/internal/merge/RecursiveModelMerger.java @@ -309,8 +309,13 @@ public class RecursiveModelMerger extends RecursiveMerger { private void indexModelMergedFiles() throws CorruptObjectException, MissingObjectException, IncorrectObjectTypeException, IOException { try (TreeWalk syncingTreeWalk = new TreeWalk(getRepository())) { - syncingTreeWalk.addTree(new DirCacheIterator(dircache)); - syncingTreeWalk.addTree(new FileTreeIterator(getRepository())); + int dirCacheIndex = syncingTreeWalk.addTree(new DirCacheIterator(dircache)); + + // Setting the DirCacheIterator is required to be able to handle properly Git attributes + FileTreeIterator aWorkingTreeIterator = new FileTreeIterator(getRepository()); + syncingTreeWalk.addTree(aWorkingTreeIterator); + aWorkingTreeIterator.setDirCacheIterator(syncingTreeWalk, dirCacheIndex); + syncingTreeWalk.setRecursive(true); syncingTreeWalk.setFilter(PathFilterGroup.createFromStrings(makeInSync)); String lastAdded = null; -- 2.11.4.GIT