Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java107
1 files changed, 10 insertions, 97 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
index 490cc17571..9a3012cc15 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
@@ -14,7 +14,6 @@
package org.eclipse.egit.ui.internal.actions;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -27,14 +26,15 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.egit.core.AdaptableFileTreeIterator;
+import org.eclipse.jgit.lib.IndexDiff;
import org.eclipse.egit.core.op.CommitOperation;
-import org.eclipse.egit.core.project.GitProjectData;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
@@ -45,19 +45,12 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Commit;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.GitIndex;
-import org.eclipse.jgit.lib.IndexDiff;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
-import org.eclipse.jgit.lib.Tree;
-import org.eclipse.jgit.lib.TreeEntry;
import org.eclipse.jgit.lib.UserConfig;
-import org.eclipse.jgit.lib.GitIndex.Entry;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
import org.eclipse.ui.PlatformUI;
/**
@@ -93,10 +86,6 @@ public class CommitActionHandler extends RepositoryActionHandler {
Activator.handleError(UIText.CommitAction_errorComputingDiffs, e,
true);
return null;
- } catch (CoreException e) {
- Activator.handleError(UIText.CommitAction_errorComputingDiffs, e,
- true);
- return null;
}
Repository[] repos = getRepositoriesFor(getProjectsForSelectedResources(event));
@@ -257,7 +246,7 @@ public class CommitActionHandler extends RepositoryActionHandler {
}
private void buildIndexHeadDiffList(ExecutionEvent event)
- throws IOException, CoreException, ExecutionException {
+ throws IOException, ExecutionException {
HashMap<Repository, HashSet<IProject>> repositories = new HashMap<Repository, HashSet<IProject>>();
for (IProject project : getProjectsInRepositoryOfSelectedResources(event)) {
@@ -282,9 +271,11 @@ public class CommitActionHandler extends RepositoryActionHandler {
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);
+ AdaptableFileTreeIterator fileTreeIterator =
+ new AdaptableFileTreeIterator(repository.getWorkTree(),
+ ResourcesPlugin.getWorkspace().getRoot());
+
+ IndexDiff indexDiff = new IndexDiff(repository, Constants.HEAD, fileTreeIterator);
indexDiff.diff();
for (IProject project : projects) {
@@ -293,47 +284,11 @@ public class CommitActionHandler extends RepositoryActionHandler {
includeList(project, indexDiff.getRemoved(), indexChanges);
includeList(project, indexDiff.getMissing(), notIndexed);
includeList(project, indexDiff.getModified(), notIndexed);
- addUntrackedFiles(repository, project);
+ includeList(project, indexDiff.getUntracked(), notTracked);
}
}
}
- private void addUntrackedFiles(final Repository repository,
- final IProject project) throws CoreException, IOException {
- final GitIndex index = repository.getIndex();
- final Tree headTree = repository.mapTree(Constants.HEAD);
- project.accept(new IResourceVisitor() {
-
- public boolean visit(IResource resource) throws CoreException {
- if (Team.isIgnoredHint(resource))
- return false;
- if (resource.getType() == IResource.FILE) {
-
- String repoRelativePath = RepositoryMapping.getMapping(
- project).getRepoRelativePath(resource);
- try {
- TreeEntry headEntry = (headTree == null ? null
- : headTree.findBlobMember(repoRelativePath));
- if (headEntry == null) {
- Entry indexEntry = null;
- indexEntry = index.getEntry(repoRelativePath);
-
- if (indexEntry == null) {
- notTracked.add((IFile) resource);
- files.add((IFile) resource);
- }
- }
- } catch (IOException e) {
- throw new TeamException(
- UIText.CommitAction_InternalError, e);
- }
- }
- return true;
- }
- });
-
- }
-
private void includeList(IProject project, HashSet<String> added,
ArrayList<IFile> category) {
String repoRelativePath = RepositoryMapping.getMapping(project)
@@ -362,48 +317,6 @@ public class CommitActionHandler extends RepositoryActionHandler {
}
}
- boolean tryAddResource(IFile resource, GitProjectData projectData,
- ArrayList<IFile> category) {
- if (files.contains(resource))
- return false;
-
- try {
- RepositoryMapping repositoryMapping = projectData
- .getRepositoryMapping(resource);
-
- if (isChanged(repositoryMapping, resource)) {
- files.add(resource);
- category.add(resource);
- return true;
- }
- } catch (Exception e) {
- if (GitTraceLocation.UI.isActive())
- GitTraceLocation.getTrace().trace(
- GitTraceLocation.UI.getLocation(), e.getMessage(), e);
- }
- return false;
- }
-
- private boolean isChanged(RepositoryMapping map, IFile resource) {
- try {
- Repository repository = map.getRepository();
- GitIndex index = repository.getIndex();
- String repoRelativePath = map.getRepoRelativePath(resource);
- Entry entry = index.getEntry(repoRelativePath);
- if (entry != null)
- return entry.isModified(map.getWorkTree());
- return false;
- } catch (UnsupportedEncodingException e) {
- if (GitTraceLocation.UI.isActive())
- GitTraceLocation.getTrace().trace(
- GitTraceLocation.UI.getLocation(), e.getMessage(), e);
- } catch (IOException e) {
- if (GitTraceLocation.UI.isActive())
- GitTraceLocation.getTrace().trace(
- GitTraceLocation.UI.getLocation(), e.getMessage(), e);
- }
- return false;
- }
@Override
public boolean isEnabled() {

Back to the top