aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-06-19 12:02:51 (EDT)
committerDariusz Luksza2010-06-19 18:30:23 (EDT)
commitba6eb8c99f603e5d570785d9d9a4a165bf8a34ba (patch)
treeb39bd0cfffe0c28b126563b95dedae0db94407e9
parent47f1635b58cfce81ad407e76093a572ace32b37f (diff)
downloadegit-ba6eb8c99f603e5d570785d9d9a4a165bf8a34ba.zip
egit-ba6eb8c99f603e5d570785d9d9a4a165bf8a34ba.tar.gz
egit-ba6eb8c99f603e5d570785d9d9a4a165bf8a34ba.tar.bz2
Fixes strange result set in Synchronize view on Windowsrefs/changes/04/904/2
On Windows platform Synchronize view returns strange result set when comparing two branches of tags without local changes. This issue occurs of different file separator char on this platform. In Git we always use UNIX file separator char for saving file paths. When we want retrieve a file content from Git repository we should replace all windows file separators with UNIX separators. Bug: 317362 Change-Id: Id85fe3ca802390c42810f7391e16ec9b329141ec Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java45
1 files changed, 26 insertions, 19 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java
index 5984a50..bcfa476 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java
@@ -397,29 +397,36 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree {
Set<IResource> membersSet = new HashSet<IResource>();
for (IResource member : members) {
- if (member.getType() == IResource.FILE) {
- String repoWorkDir = repo.getWorkDir().toString();
- String memberRelPath = member.getLocation().toString();
- memberRelPath = memberRelPath.replace(repoWorkDir, ""); //$NON-NLS-1$
- if (memberRelPath.startsWith(File.separator)) {
- memberRelPath = memberRelPath.substring(1);
- }
+ String memberRelPath = getMemberRelPath(repo, member);
+
+ // check if this file exists in repository
+ if (tree.existsBlob(memberRelPath)) {
+ // read file content and add it into store
TreeEntry entry = tree.findBlobMember(memberRelPath);
- if (entry != null) {
- ObjectLoader objLoader = repo.openBlob(entry.getId());
- store.setBytes(member, objLoader.getCachedBytes());
- membersSet.add(member);
- }
- } else if (member.getType() == IResource.FOLDER ) {
- try {
- IResource[] resources = ((IContainer) member).members();
- membersSet.addAll(getAllMembers(repo, tree, resources));
- } catch (CoreException e) {
- throw new TeamException(e.getStatus());
- }
+ ObjectLoader objLoader = repo.openBlob(entry.getId());
+ store.setBytes(member, objLoader.getCachedBytes());
+ membersSet.add(member);
+ } else if (tree.existsTree(memberRelPath)) {
+ // add to members if folder exists in repository
+ membersSet.add(member);
}
}
return membersSet;
}
+ private String getMemberRelPath(Repository repo, IResource member) {
+ String repoWorkDir = repo.getWorkDir().toString();
+ if (!"/".equals(File.separator)) { //$NON-NLS-1$
+ // fix file separator issue on windows
+ repoWorkDir = repoWorkDir.replace(File.separatorChar, '/');
+ }
+
+ String memberRelPath = member.getLocation().toString();
+ memberRelPath = memberRelPath.replace(repoWorkDir, ""); //$NON-NLS-1$
+ if (memberRelPath.startsWith("/"))//$NON-NLS-1$
+ memberRelPath = memberRelPath.substring(1);
+
+ return memberRelPath;
+ }
+
}