summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMarkus Duft2012-03-13 11:55:18 (EDT)
committer Markus Duft2012-03-13 11:55:18 (EDT)
commit4687b964d71e66dd0edcf62552ab5c580aa643d9 (patch)
tree370fcb079b825531b64b6aed183f8620e231ce85
parentbee5b6724742e9bdcf5ed1a58069ca870f6f7c8a (diff)
downloadegit-4687b964d71e66dd0edcf62552ab5c580aa643d9.zip
egit-4687b964d71e66dd0edcf62552ab5c580aa643d9.tar.gz
egit-4687b964d71e66dd0edcf62552ab5c580aa643d9.tar.bz2
Make the staging view use the IndexDiffCacherefs/changes/99/5299/9
This makes the staging view no longer use a separate "Staging view indexer job", but rather uses the already existent IndexDiffCacheEntry for the selected repository. Change-Id: Ia2ed34f57e4639fd086b65ce421dfc7613f93f57 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java300
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java24
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties2
6 files changed, 74 insertions, 267 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
index 2bb1554..7f4f47d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
@@ -14,8 +14,8 @@ import static org.junit.Assert.fail;
import java.io.File;
+import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.common.StagingViewTester;
import org.eclipse.egit.ui.test.CommitMessageUtil;
@@ -61,7 +61,7 @@ public class StagingViewTest extends LocalRepositoryTestCase {
StagingViewTester stagingViewTester = StagingViewTester
.openStagingView();
selectRepositoryNode();
- TestUtil.joinJobs(JobFamilies.STAGING_VIEW_REFRESH);
+ TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
stagingViewTester.setAuthor(TestUtil.TESTAUTHOR);
stagingViewTester.setCommitter(TestUtil.TESTCOMMITTER);
stagingViewTester.setCommitMessage("The new commit");
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
index 893251c..3207d44 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
@@ -89,11 +89,6 @@ public class JobFamilies {
public final static Object DISCONNECT = new Object();
/**
- * Staging View refresh
- */
- public static final Object STAGING_VIEW_REFRESH = new Object();
-
- /**
* Add to index job
*/
public static final Object ADD_TO_INDEX = new Object();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index c8c52a9..48ea571 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -4241,9 +4241,6 @@ public class UIText extends NLS {
public static String StagingView_ColumnLayout;
/** */
- public static String StagingView_IndexDiffReload;
-
- /** */
public static String StagingView_Refresh;
/** */
@@ -4262,6 +4259,9 @@ public class UIText extends NLS {
public static String StagingView_StageItemMenuLabel;
/** */
+ public static String StagingViewContentProvider_SubmoduleError;
+
+ /** */
public static String StashApplyCommand_applyFailed;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 6f00daf..bf8c1ac 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -17,38 +17,25 @@ import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.egit.core.EclipseGitProgressTransformer;
import org.eclipse.egit.core.RepositoryUtil;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffChangedListener;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
import org.eclipse.egit.core.op.CommitOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
@@ -95,23 +82,14 @@ import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheEditor;
import org.eclipse.jgit.dircache.DirCacheEntry;
-import org.eclipse.jgit.events.IndexChangedEvent;
-import org.eclipse.jgit.events.IndexChangedListener;
-import org.eclipse.jgit.events.ListenerHandle;
-import org.eclipse.jgit.events.RefsChangedEvent;
-import org.eclipse.jgit.events.RefsChangedListener;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.IndexDiff;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
-import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.TreeWalk;
-import org.eclipse.jgit.treewalk.WorkingTreeIterator;
-import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -128,7 +106,6 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.team.core.Team;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
@@ -149,7 +126,6 @@ import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;
import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
/**
* A GitX style staging view with embedded commit dialog.
@@ -185,21 +161,17 @@ public class StagingView extends ViewPart {
private boolean reactOnSelection = true;
- private final List<ListenerHandle> myListeners = new LinkedList<ListenerHandle>();
-
private ISelectionListener selectionChangedListener;
- private IResourceChangeListener resourceChangeListener;
-
private Repository currentRepository;
static class StagingViewUpdate {
Repository repository;
- IndexDiff indexDiff;
+ IndexDiffData indexDiff;
Collection<String> changedResources;
StagingViewUpdate(Repository theRepository,
- IndexDiff theIndexDiff, Collection<String> theChanges) {
+ IndexDiffData theIndexDiff, Collection<String> theChanges) {
this.repository = theRepository;
this.indexDiff = theIndexDiff;
this.changedResources = theChanges;
@@ -255,29 +227,6 @@ public class StagingView extends ViewPart {
}
}
- /**
- * Bit-mask describing interesting changes for IResourceChangeListener
- * events
- */
- private static int INTERESTING_CHANGES = IResourceDelta.CONTENT
- | IResourceDelta.MOVED_FROM | IResourceDelta.MOVED_TO
- | IResourceDelta.OPEN | IResourceDelta.REPLACED
- | IResourceDelta.TYPE;
-
- private final RefsChangedListener myRefsChangedListener = new RefsChangedListener() {
- public void onRefsChanged(RefsChangedEvent event) {
- // refs change when files are committed, we naturally want to remove
- // committed files from the view
- reload(event.getRepository());
- }
- };
-
- private final IndexChangedListener myIndexChangedListener = new IndexChangedListener() {
- public void onIndexChanged(IndexChangedEvent event) {
- reload(event.getRepository());
- }
- };
-
private final IPreferenceChangeListener prefListener = new IPreferenceChangeListener() {
public void preferenceChange(PreferenceChangeEvent event) {
@@ -312,7 +261,14 @@ public class StagingView extends ViewPart {
private SashForm stagingSashForm;
- private Job reloadJob;
+ private IndexDiffChangedListener myIndexDiffListener = new IndexDiffChangedListener() {
+ public void indexDiffChanged(Repository repository,
+ IndexDiffData indexDiffData) {
+ reload(repository);
+ }
+ };
+
+ private IndexDiffCacheEntry cacheEntry;
@Override
public void createPartControl(Composite parent) {
@@ -506,78 +462,6 @@ public class StagingView extends ViewPart {
org.eclipse.egit.core.Activator.getPluginId())
.addPreferenceChangeListener(prefListener);
- resourceChangeListener = new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
- final Collection<String> resourcesToUpdate = new HashSet<String>();
-
- try {
- event.getDelta().accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- // If the file has changed but not in a way that we care
- // about (e.g. marker changes to files) then ignore
- if (delta.getKind() == IResourceDelta.CHANGED
- && (delta.getFlags() & INTERESTING_CHANGES) == 0)
- return true;
-
- final IResource resource = delta.getResource();
-
- // skip any non-FILE resources
- if (resource.getType() != IResource.FILE)
- return true;
-
- // If the resource is not part of a project under Git
- // revision control
- final RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
- if (mapping == null || mapping.getRepository() != currentRepository)
- // Ignore the change
- return true;
-
- // Don't include ignored resources
- if (Team.isIgnoredHint(resource))
- return false;
-
- String repoRelativePath = mapping.getRepoRelativePath(resource);
- resourcesToUpdate.add(repoRelativePath);
-
- return true;
- }
- });
- } catch (CoreException e) {
- MessageDialog.openError(getSite().getShell(),
- UIText.StagingView_exceptionTitle,
- UIText.StagingView_exceptionMessage);
- }
-
- if (!resourcesToUpdate.isEmpty()) {
- final IndexDiff indexDiff;
- try {
- WorkingTreeIterator iterator = new FileTreeIterator(
- currentRepository);
- indexDiff = new IndexDiff(currentRepository, Constants.HEAD, iterator);
- indexDiff.setFilter(PathFilterGroup.createFromStrings(resourcesToUpdate));
- indexDiff.diff();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- final StagingViewUpdate update = new StagingViewUpdate(currentRepository, indexDiff, resourcesToUpdate);
- asyncExec(new Runnable() {
- public void run() {
- if (form.isDisposed())
- return;
-
- unstagedTableViewer.setInput(update);
- stagedTableViewer.setInput(update);
-
- updateSectionText();
- }
- });
- }
- }
- };
- ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener,
- IResourceChangeEvent.POST_CHANGE);
-
updateSectionText();
updateToolbar();
enableCommitWidgets(false);
@@ -648,7 +532,8 @@ public class StagingView extends ViewPart {
refreshAction = new Action(UIText.StagingView_Refresh, IAction.AS_PUSH_BUTTON) {
public void run() {
- reload(currentRepository);
+ if(cacheEntry != null)
+ cacheEntry.refresh();
}
};
refreshAction.setImageDescriptor(UIIcons.ELCL16_REFRESH);
@@ -940,22 +825,8 @@ public class StagingView extends ViewPart {
RepositoryMapping mapping = RepositoryMapping.getMapping(project);
if (mapping == null)
return;
- if (mapping.getRepository() != currentRepository) {
+ if (mapping.getRepository() != currentRepository)
reload(mapping.getRepository());
- }
- }
-
- private void attachListeners(Repository repository) {
- myListeners.add(repository.getListenerList().addIndexChangedListener(
- myIndexChangedListener));
- myListeners.add(repository.getListenerList().addRefsChangedListener(
- myRefsChangedListener));
- }
-
- private void removeListeners() {
- for (ListenerHandle lh : myListeners)
- lh.remove();
- myListeners.clear();
}
private void stage(IStructuredSelection selection) {
@@ -999,8 +870,6 @@ public class StagingView extends ViewPart {
} catch (NoFilepatternException e) {
// cannot happen
}
-
- reload(currentRepository);
}
private void unstage(IStructuredSelection selection) {
@@ -1050,8 +919,6 @@ public class StagingView extends ViewPart {
} finally {
dirCache.unlock();
}
-
- reload(currentRepository);
}
private void updateDirCache(IStructuredSelection selection,
@@ -1069,7 +936,7 @@ public class StagingView extends ViewPart {
try {
final TreeWalk tw = TreeWalk.forPath(currentRepository,
entry.getPath(), headRev.getTree());
- if (tw != null) {
+ if (tw != null)
edit.add(new DirCacheEditor.PathEdit(entry.getPath()) {
@Override
public void apply(DirCacheEntry ent) {
@@ -1079,7 +946,6 @@ public class StagingView extends ViewPart {
ent.setLastModified(0);
}
});
- }
} catch (IOException e) {
// TODO fix text
MessageDialog.openError(getSite().getShell(),
@@ -1109,7 +975,6 @@ public class StagingView extends ViewPart {
private void clearRepository() {
saveCommitMessageComponentState();
currentRepository = null;
- removeListeners();
StagingViewUpdate update = new StagingViewUpdate(null, null, null);
unstagedTableViewer.setInput(update);
stagedTableViewer.setInput(update);
@@ -1123,7 +988,6 @@ public class StagingView extends ViewPart {
return;
if (repository == null) {
asyncExec(new Runnable() {
-
public void run() {
clearRepository();
}
@@ -1136,95 +1000,41 @@ public class StagingView extends ViewPart {
final boolean repositoryChanged = currentRepository != repository;
- final AtomicReference<IndexDiff> results = new AtomicReference<IndexDiff>();
-
- final String jobTitle = MessageFormat.format(UIText.StagingView_IndexDiffReload,
- StagingView.getRepositoryName(repository));
-
- if (reloadJob != null)
- reloadJob.cancel();
- reloadJob = new Job(jobTitle) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IndexDiff indexDiff = doReload(repository, monitor, jobTitle);
- results.set(indexDiff);
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- return Status.OK_STATUS;
- }
-
- @Override
- public boolean belongsTo(Object family) {
- if (family.equals(JobFamilies.STAGING_VIEW_REFRESH))
- return true;
- return super.belongsTo(family);
- }
-
- };
+ asyncExec(new Runnable() {
+ public void run() {
+ if (form.isDisposed())
+ return;
- reloadJob.setUser(false);
- reloadJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ final IndexDiffData indexDiff = doReload(repository);
- reloadJob.addJobChangeListener(new JobChangeAdapter() {
- public void done(final IJobChangeEvent event) {
- if (!event.getResult().isOK())
+ if(indexDiff == null)
return;
- asyncExec(new Runnable() {
- public void run() {
- if (form.isDisposed())
- return;
- final IndexDiff indexDiff = results.get();
- final StagingViewUpdate update = new StagingViewUpdate(currentRepository, indexDiff, null);
- unstagedTableViewer.setInput(update);
- stagedTableViewer.setInput(update);
- enableCommitWidgets(true);
- commitAction.setEnabled(repository.getRepositoryState()
- .canCommit());
- form.setText(StagingView.getRepositoryName(repository));
- updateCommitMessageComponent(repositoryChanged);
- updateSectionText();
- }
- });
+ final StagingViewUpdate update = new StagingViewUpdate(currentRepository, indexDiff, null);
+ unstagedTableViewer.setInput(update);
+ stagedTableViewer.setInput(update);
+ enableCommitWidgets(true);
+ commitAction.setEnabled(repository.getRepositoryState()
+ .canCommit());
+ form.setText(StagingView.getRepositoryName(repository));
+ updateCommitMessageComponent(repositoryChanged);
+ updateSectionText();
}
});
-
- schedule(reloadJob);
}
- private void schedule(final Job j) {
- IWorkbenchPartSite site = getSite();
- if (site != null) {
- final IWorkbenchSiteProgressService p;
- p = (IWorkbenchSiteProgressService) site
- .getAdapter(IWorkbenchSiteProgressService.class);
- if (p != null) {
- p.schedule(j, 0, true /* use half-busy cursor */);
- return;
- }
- }
- j.schedule();
- }
-
- private IndexDiff doReload(final Repository repository, IProgressMonitor monitor, String jobTitle) {
+ private IndexDiffData doReload(final Repository repository) {
currentRepository = repository;
- EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(
- monitor);
+ IndexDiffCacheEntry entry = org.eclipse.egit.core.Activator.getDefault().getIndexDiffCache().getIndexDiffCacheEntry(currentRepository);
- final IndexDiff indexDiff;
- try {
- WorkingTreeIterator iterator = new FileTreeIterator(repository);
- indexDiff = new IndexDiff(repository, Constants.HEAD, iterator);
- indexDiff.diff(jgitMonitor, 0, 0, jobTitle);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ if(cacheEntry != null && cacheEntry != entry)
+ cacheEntry.removeIndexDiffChangedListener(myIndexDiffListener);
- removeListeners();
- attachListeners(repository);
+ cacheEntry = entry;
+ cacheEntry.addIndexDiffChangedListener(myIndexDiffListener);
- return indexDiff;
+ return cacheEntry.getIndexDiff();
}
private void clearCommitMessageToggles() {
@@ -1243,13 +1053,11 @@ public class StagingView extends ViewPart {
deleteCommitMessageComponentState();
oldState = loadCommitMessageComponentState();
commitMessageComponent.setRepository(currentRepository);
- if (oldState == null) {
+ if (oldState == null)
loadInitialState(helper);
- } else {
+ else
loadExistingState(helper, oldState);
- }
- } else {
- // repository did not change
+ } else // repository did not change
if (userEnteredCommmitMessage()) {
if (!commitMessageComponent.getHeadCommit().equals(
helper.getPreviousCommit()))
@@ -1257,7 +1065,6 @@ public class StagingView extends ViewPart {
.getCommitMessage());
} else
loadInitialState(helper);
- }
amendPreviousCommitAction.setChecked(commitMessageComponent
.isAmending());
amendPreviousCommitAction.setEnabled(helper.amendAllowed());
@@ -1279,14 +1086,12 @@ public class StagingView extends ViewPart {
.getPreviousCommit()));
boolean amendAllowed = helper.amendAllowed();
commitMessageComponent.setAmendAllowed(amendAllowed);
- if (!amendAllowed) {
+ if (!amendAllowed)
+ commitMessageComponent.setAmending(false);
+ else if (!headCommitChanged && oldState.getAmend())
+ commitMessageComponent.setAmending(true);
+ else
commitMessageComponent.setAmending(false);
- } else {
- if (!headCommitChanged && oldState.getAmend())
- commitMessageComponent.setAmending(true);
- else
- commitMessageComponent.setAmending(false);
- }
commitMessageComponent.updateUIFromState();
commitMessageComponent.updateSignedOffAndChangeIdButton();
commitMessageComponent.enableListers(true);
@@ -1398,16 +1203,13 @@ public class StagingView extends ViewPart {
ISelectionService srv = (ISelectionService) getSite().getService(
ISelectionService.class);
srv.removePostSelectionListener(selectionChangedListener);
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
+
+ if(cacheEntry != null)
+ cacheEntry.removeIndexDiffChangedListener(myIndexDiffListener);
+
new InstanceScope().getNode(
org.eclipse.egit.core.Activator.getPluginId())
.removePreferenceChangeListener(prefListener);
-
- removeListeners();
- if (reloadJob != null) {
- reloadJob.cancel();
- reloadJob = null;
- }
}
private void asyncExec(Runnable runnable) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
index 8790f63..f447783 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
@@ -17,17 +17,20 @@ import static org.eclipse.egit.ui.internal.staging.StagingEntry.State.PARTIALLY_
import static org.eclipse.egit.ui.internal.staging.StagingEntry.State.REMOVED;
import static org.eclipse.egit.ui.internal.staging.StagingEntry.State.UNTRACKED;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.staging.StagingView.StagingViewUpdate;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jgit.lib.FileMode;
-import org.eclipse.jgit.lib.IndexDiff;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.submodule.SubmoduleWalk;
/**
* ContentProvider for staged and unstaged table nodes
@@ -73,18 +76,17 @@ public class StagingViewContentProvider implements
nodes.remove(entry);
}
- final IndexDiff indexDiff = update.indexDiff;
+ final IndexDiffData indexDiff = update.indexDiff;
final Repository repository = update.repository;
if (isWorkspace) {
for (String file : indexDiff.getMissing())
nodes.add(new StagingEntry(repository, MISSING, file));
- for (String file : indexDiff.getModified()) {
+ for (String file : indexDiff.getModified())
if (indexDiff.getChanged().contains(file))
nodes.add(new StagingEntry(repository, PARTIALLY_MODIFIED,
file));
else
nodes.add(new StagingEntry(repository, MODIFIED, file));
- }
for (String file : indexDiff.getUntracked())
nodes.add(new StagingEntry(repository, UNTRACKED, file));
for (String file : indexDiff.getConflicting())
@@ -97,8 +99,16 @@ public class StagingViewContentProvider implements
for (String file : indexDiff.getRemoved())
nodes.add(new StagingEntry(repository, REMOVED, file));
}
- for (StagingEntry entry : nodes)
- entry.setSubmodule(indexDiff.getIndexMode(entry.getPath()) == FileMode.GITLINK);
+
+ try {
+ SubmoduleWalk walk = SubmoduleWalk.forIndex(repository);
+ while(walk.next())
+ for (StagingEntry entry : nodes)
+ entry.setSubmodule(entry.getPath().equals(walk.getPath()));
+ } catch(IOException e) {
+ Activator.error(UIText.StagingViewContentProvider_SubmoduleError, e);
+ }
+
content = nodes.toArray(new StagingEntry[nodes.size()]);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 147505b..4eda545 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -1479,13 +1479,13 @@ StagingView_noStagedFiles=There are no staged files
StagingView_NoSelectionTitle=No Repository Selected
StagingView_OpenNewCommits=Open New Commits
StagingView_ColumnLayout=Column Layout
-StagingView_IndexDiffReload=Staging view reindexing repository {0}
StagingView_Refresh=Refresh
StagingView_LinkSelection=Link with Editor and Selection
StagingView_exceptionTitle=Refresh Error
StagingView_exceptionMessage=Errors occurred while applying processing change notifications.
StagingView_UnstageItemMenuLabel=Remove from Git Index
StagingView_StageItemMenuLabel=Add to Git Index
+StagingViewContentProvider_SubmoduleError=Unhandled exception while analyzing submodules
StashApplyCommand_applyFailed=Applying stashed commit ''{0}'' failed
StashApplyCommand_jobTitle=Apply changes from stashed commit ''{0}''
StashCreateCommand_jobTitle=Stashing local changes