summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAuke Schrijnen2010-04-08 10:53:57 (EDT)
committer Stefan Lay2010-04-08 10:53:57 (EDT)
commitdcd931cb2f0d39bb9cfbb4d2206fe08e34eeaed9 (patch)
tree30904bc800f2269608debbce3b7f19a68651948a
parent895dde83f07e7dcf00d0df2c240369cae63f76cb (diff)
downloadegit-dcd931cb2f0d39bb9cfbb4d2206fe08e34eeaed9.zip
egit-dcd931cb2f0d39bb9cfbb4d2206fe08e34eeaed9.tar.gz
egit-dcd931cb2f0d39bb9cfbb4d2206fe08e34eeaed9.tar.bz2
Create index diff only once per repositoryrefs/changes/27/527/2
When a git repository contains multiple eclipse projects there is no need to create an index diff for every project when creating a commit. Change-Id: I839931ad3d1ffa4e34e87e3816b21934e15a98b4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java
index 8903496..d190103 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.TimeZone;
import org.eclipse.core.resources.IFile;
@@ -348,20 +349,40 @@ public class CommitAction extends RepositoryAction {
}
private void buildIndexHeadDiffList() throws IOException {
+ HashMap<Repository, HashSet<IProject>> repositories = new HashMap<Repository, HashSet<IProject>>();
+
for (IProject project : getProjectsInRepositoryOfSelectedResources()) {
RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(project);
assert repositoryMapping != null;
+
Repository repository = repositoryMapping.getRepository();
+
+ HashSet<IProject> projects = repositories.get(repository);
+
+ if (projects == null) {
+ projects = new HashSet<IProject>();
+ repositories.put(repository, projects);
+ }
+
+ projects.add(project);
+ }
+
+ for (Map.Entry<Repository, HashSet<IProject>> entry : repositories.entrySet()) {
+ Repository repository = entry.getKey();
+ HashSet<IProject> projects = entry.getValue();
+
Tree head = repository.mapTree(Constants.HEAD);
GitIndex index = repository.getIndex();
IndexDiff indexDiff = new IndexDiff(head, index);
indexDiff.diff();
- includeList(project, indexDiff.getAdded(), indexChanges);
- includeList(project, indexDiff.getChanged(), indexChanges);
- includeList(project, indexDiff.getRemoved(), indexChanges);
- includeList(project, indexDiff.getMissing(), notIndexed);
- includeList(project, indexDiff.getModified(), notIndexed);
+ for (IProject project : projects) {
+ includeList(project, indexDiff.getAdded(), indexChanges);
+ includeList(project, indexDiff.getChanged(), indexChanges);
+ includeList(project, indexDiff.getRemoved(), indexChanges);
+ includeList(project, indexDiff.getMissing(), notIndexed);
+ includeList(project, indexDiff.getModified(), notIndexed);
+ }
}
}