Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2017-11-23 19:58:40 -0500
committerMatthias Sohn2017-11-23 19:58:40 -0500
commitae2f1ca386404ce7e21dd41d4c35da476efdcf11 (patch)
treea3467af1145cfad15bb9765c587739da3736622a
parenteea360f47ead2420782abcc2739d500607455fde (diff)
parent655e3db2849133b1f57e3cada3aff003726737c3 (diff)
downloadegit-ae2f1ca386404ce7e21dd41d4c35da476efdcf11.tar.gz
egit-ae2f1ca386404ce7e21dd41d4c35da476efdcf11.tar.xz
egit-ae2f1ca386404ce7e21dd41d4c35da476efdcf11.zip
Merge branch 'stable-4.9'
* stable-4.9: Make commit viewer diff list scrollable Prevent NPEs on bare repositories [test stability] CompareActionsTest assumes resource model Prepare 4.9.1-SNAPSHOT builds EGit v4.9.0.201710071750-r Change-Id: Id8c75458d5edf1d5b5582e9d12481f948f9c080b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java24
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageBuilder.java17
4 files changed, 42 insertions, 16 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
index 1fe0845b1..cda0d6db1 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
@@ -68,9 +68,12 @@ public class ProjectUtil {
*/
public static IProject[] getValidOpenProjects(Repository repository)
throws CoreException {
+ if (repository == null || repository.isBare()) {
+ return new IProject[0];
+ }
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
.getProjects();
- List<IProject> result = new ArrayList<IProject>();
+ List<IProject> result = new ArrayList<>();
final Path repositoryPath = new Path(
repository.getWorkTree().getAbsolutePath());
for (IProject p : projects) {
@@ -243,6 +246,9 @@ public class ProjectUtil {
public static void refreshRepositoryResources(Repository repository,
Collection<String> relativePaths, IProgressMonitor monitor)
throws CoreException {
+ if (repository == null || repository.isBare()) {
+ return;
+ }
if (relativePaths.isEmpty() || relativePaths.contains("")) { //$NON-NLS-1$
refreshResources(getProjects(repository), monitor);
return;
@@ -250,7 +256,7 @@ public class ProjectUtil {
IPath repositoryPath = new Path(repository.getWorkTree().getAbsolutePath());
IProject[] projects = null;
- Set<IResource> resources = new LinkedHashSet<IResource>();
+ Set<IResource> resources = new LinkedHashSet<>();
for (String relativePath : relativePaths) {
IPath location = repositoryPath.append(relativePath);
IResource resource = ResourceUtil
@@ -283,7 +289,10 @@ public class ProjectUtil {
* @return list of projects, with nested projects first.
*/
public static IProject[] getProjects(Repository repository) {
- List<IProject> result = new ArrayList<IProject>();
+ if (repository == null || repository.isBare()) {
+ return new IProject[0];
+ }
+ List<IProject> result = new ArrayList<>();
for (IProject project : getProjectsUnderPath(
new Path(repository.getWorkTree().getAbsolutePath()))) {
RepositoryMapping mapping = RepositoryMapping.getMapping(project);
@@ -307,7 +316,10 @@ public class ProjectUtil {
*/
public static IProject[] getProjectsContaining(Repository repository,
Collection<String> fileList) throws CoreException {
- Set<IProject> result = new LinkedHashSet<IProject>();
+ if (repository == null || repository.isBare()) {
+ return new IProject[0];
+ }
+ Set<IProject> result = new LinkedHashSet<>();
File workTree = repository.getWorkTree();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -402,7 +414,7 @@ public class ProjectUtil {
public static IProject[] getProjectsUnderPath(@NonNull final IPath path) {
IProject[] allProjects = getProjectsForContainerMatch(ResourcesPlugin
.getWorkspace().getRoot());
- Set<IProject> projects = new HashSet<IProject>();
+ Set<IProject> projects = new HashSet<>();
for (IProject p : allProjects) {
IPath loc = p.getLocation();
if (loc != null && path.isPrefixOf(loc)) {
@@ -457,7 +469,7 @@ public class ProjectUtil {
Set<String> directoriesVisited;
// Initialize recursion guard for recursive symbolic links
if (visistedDirs == null) {
- directoriesVisited = new HashSet<String>();
+ directoriesVisited = new HashSet<>();
directoriesVisited.add(directory.getAbsolutePath());
} else
directoriesVisited = visistedDirs;
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
index f863e9b2f..df76d02b5 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.util.concurrent.TimeUnit;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.op.ResetOperation;
import org.eclipse.egit.core.op.TagOperation;
@@ -55,6 +56,9 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
+import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
import org.eclipse.team.ui.synchronize.ISynchronizeView;
import org.junit.Before;
@@ -77,6 +81,7 @@ public class CompareActionsTest extends LocalRepositoryTestCase {
Repository repo = lookupRepository(repositoryFile);
disablePerspectiveSwitchPrompt();
+ setEnabledModelProvider(ModelProvider.RESOURCE_MODEL_PROVIDER_ID);
TagBuilder tag = new TagBuilder();
tag.setTag("SomeTag");
@@ -97,6 +102,15 @@ public class CompareActionsTest extends LocalRepositoryTestCase {
repo));
}
+ private static void setEnabledModelProvider(String modelProviderId) {
+ ITeamContentProviderManager contentProviderManager = TeamUI
+ .getTeamContentProviderManager();
+ ITeamContentProviderDescriptor descriptor = contentProviderManager
+ .getDescriptor(modelProviderId);
+ contentProviderManager.setEnabledDescriptors(
+ new ITeamContentProviderDescriptor[] { descriptor });
+ }
+
@SuppressWarnings("restriction")
private static void disablePerspectiveSwitchPrompt() {
// disable perspective synchronize selection
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
index 1012cebdb..198e61fa3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
@@ -518,7 +518,8 @@ public class CommitEditorPage extends FormPage
| toolkit.getBorderStyle());
Control control = diffViewer.getControl();
control.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(control);
+ GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 50).minSize(1, 50)
+ .grab(true, true).applyTo(control);
addToFocusTracking(control);
diffViewer.setContentProvider(ArrayContentProvider.getInstance());
diffViewer.setTreeWalk(getCommit().getRepository(), null);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageBuilder.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageBuilder.java
index d841f8ee6..3f20a93f3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageBuilder.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageBuilder.java
@@ -29,7 +29,6 @@ import org.eclipse.egit.ui.CommitMessageWithCaretPosition;
import org.eclipse.egit.ui.ICommitMessageProvider;
import org.eclipse.egit.ui.ICommitMessageProvider2;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.Repository;
class CommitMessageBuilder {
@@ -43,9 +42,6 @@ class CommitMessageBuilder {
private final IResource[] resourcesArray;
- @NonNull
- private final Repository repository;
-
private boolean isMessageEmpty;
/**
@@ -53,14 +49,13 @@ class CommitMessageBuilder {
* files, that are about to be committed.
*
* @param repository
- * the repository, messages are built for
+ * the message is built for
* @param paths
* list of file paths, selected for the next commit
*/
- CommitMessageBuilder(@NonNull Repository repository,
+ CommitMessageBuilder(Repository repository,
Collection<String> paths) {
- this.repository = repository;
- this.resourcesArray = toResourceArray(paths);
+ this.resourcesArray = toResourceArray(repository, paths);
}
/**
@@ -202,7 +197,11 @@ class CommitMessageBuilder {
return providers;
}
- private IResource[] toResourceArray(Collection<String> paths) {
+ private IResource[] toResourceArray(Repository repository,
+ Collection<String> paths) {
+ if (repository == null || repository.isBare()) {
+ return new IResource[0];
+ }
Set<IResource> resources = new HashSet<>();
for (String path : paths) {
IFile file = null;

Back to the top