From: Robin Rosenberg Date: Thu, 12 Jun 2008 23:39:57 GMT Subject: [EGIT RFC] Enable commit for any resource in a Git-shared project Message-ID: <1213313997-1520-3-git-send-email-robin.rosenberg@dewire.com> In-Reply-To: <1213313997-1520-2-git-send-email-robin.rosenberg@dewire.com> By default the commit dialog will be populated with all changed resources in the projects that contain the selected resources, provided the projects are associated with a Git respository. --- .../egit/ui/internal/actions/CommitAction.java | 31 +++++++++---------- 1 files changed, 15 insertions(+), 16 deletions(-) diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java index db38c10..da32ea5 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java @@ -68,7 +68,7 @@ public class CommitAction extends RepositoryAction { return; } - Repository[] repos = getRepositories(); + Repository[] repos = getRepositoriesFor(getProjectsForSelectedResources()); amendAllowed = repos.length == 1; for (Repository repo : repos) { if (!repo.getRepositoryState().canCommit()) { @@ -313,21 +313,20 @@ public class CommitAction extends RepositoryAction { } private void buildIndexHeadDiffList() throws IOException { - for (IProject project : getSelectedProjects()) { + for (IProject project : getProjectsInRepositoryOfSelectedResources()) { RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(project); - if (repositoryMapping != null) { - Repository repository = repositoryMapping.getRepository(); - Tree head = repository.mapTree("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); - } + assert repositoryMapping != null; + Repository repository = repositoryMapping.getRepository(); + Tree head = repository.mapTree("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); } } @@ -395,7 +394,7 @@ public class CommitAction extends RepositoryAction { @Override public boolean isEnabled() { - return getRepositories().length > 0; + return getProjectsInRepositoryOfSelectedResources().length > 0; } } -- 1.5.5.1.178.g1f811