Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-05-25 11:19:45 +0000
committerMatthias Sohn2016-05-25 11:23:56 +0000
commitb21214bd3f3187208b2147f79b19646a6e6568fc (patch)
tree5f4feea151ab2e23cc98dd68bf70d929ff278f44
parent78800c6dd770fcb36fd7788ec987e79772a7044d (diff)
parentd58c936fa4cc6e1d412a419aa9f931dbd645f7f2 (diff)
downloadegit-b21214bd3f3187208b2147f79b19646a6e6568fc.tar.gz
egit-b21214bd3f3187208b2147f79b19646a6e6568fc.tar.xz
egit-b21214bd3f3187208b2147f79b19646a6e6568fc.zip
Merge branch 'master' into stable-4.4
* master: Create push wizards in CommitJob in UI thread Fix NPE in AbstractRebaseCommandHandler$1.done() Fix NPE in GitSelectRepositoryPage.refreshRepositoryList() Fix NPE in PushBranchWizard.startPush() Fix NPE in ResourceUtil.isSharedWithGit() Catch IOException in ConfigureGerritAfterCloneTask Replace uses of deprecated Repository.getRef() Ensure Git is closed using try with resource Check HandlerUtil.getActiveSite(event) result to avoid NPE's Prepare 4.3.2-SNAPSHOT builds Ensure compatibility with pre-Mars Eclipse Update Orbit repository to S20160518051658 for Neon RC2 Relayout buttons after enabling check for warnings Add accelerators for "Compare With" and "Replace With" commands New convenience commands to compare/replace with Gitflow develop branch Mark branding plugin and gitflow plugin as singletons [releng] p2.inf to remove the old importer fragment [findBugs] Fix potential NPE in RepositoryMapping Remove duplicate rename branch dialog [findBugs] Avoid unnecessary boxing when parsing int from String Replace use of deprecated Repository.getRef() method Ensure Git is closed using try with resource Remove unnecessary @SuppressWarnings("resource") Exclude labels from tab stop Mark current feature-branch and prevent attempted re-checkout Ignore SmartImportWizardTest [releng] Include missing extension point schemas in EGit binaries [releng] Importer fragment must have host bundle version constraint Leave the commit message enabled in staging view Adapt target platform to changed Neon staging p2 repository [releng] Importer fragment must have host bundle version constraint Topic input on PushToGerritPage Add "Open in Commit Viewer" in context menu of stashed commit Handle linked resources in the same repository Refactor code: simplification, and avoid findbugs warning Set repository when opening staging view from commit action Test stability: one "widget disposed" message is enough EGit v4.3.1.201605051710-r Test stability: really shut down repositories Fix typo in testcase name Fix wrong cursor position while editing URIs Test stability: wait for repositories view refresh after config change [memory leak] make sure we only allow one GitHistoryPageSource instance Prevent NPE in ProjectUtil.getProjectsUnderPath(IPath) Change-Id: I13ee8cfb7648a356dfca9e2c86b9ffb5d92ebe84 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java41
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java4
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RebaseOperationTest.java21
-rw-r--r--org.eclipse.egit.core/build.properties5
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/GitProvider.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java7
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java37
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java35
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java5
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java60
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/CherryPickOperation.java16
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/CommitOperation.java33
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureFetchAfterCloneTask.java20
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java79
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/DeleteBranchOperation.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java27
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/EditCommitOperation.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java37
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/GarbageCollectOperation.java8
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ListRemoteOperation.java7
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/MergeOperation.java68
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java64
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/RebaseOperation.java18
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java31
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameBranchOperation.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/RevertCommitOperation.java28
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/RewordCommitOperation.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/SquashCommitsOperation.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparator.java1
-rw-r--r--org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.gitflow.ui/plugin.properties6
-rw-r--r--org.eclipse.egit.gitflow.ui/plugin.xml103
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopCompareHandler.java55
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopReplaceHandler.java100
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/GitFlowHandlerUtil.java37
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/DecoratedBranchLabelProvider.java69
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FeatureBranchSelectionDialog.java22
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java33
-rw-r--r--org.eclipse.egit.gitflow/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.egit.repository/pom.xml2
-rw-r--r--org.eclipse.egit.target/egit-4.6-staging.target10
-rw-r--r--org.eclipse.egit.target/egit-4.6-staging.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.6.target8
-rw-r--r--org.eclipse.egit.target/egit-4.6.tpd2
-rw-r--r--org.eclipse.egit.target/orbit/S20160518051658-Neon.tpd (renamed from org.eclipse.egit.target/orbit/S20160501200945-Neon.tpd)8
-rw-r--r--org.eclipse.egit.target/releasetrain/staging.tpd2
-rw-r--r--org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/SmartImportWizardTest.java (renamed from org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java)4
-rw-r--r--org.eclipse.egit.ui.smartimport/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.egit.ui.smartimport/META-INF/p2.inf2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java3
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java3
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java5
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushToUpstreamTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/submodule/SubmoduleUpdateTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java9
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionStagingViewTest.java105
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java1
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java1
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java1
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java2
-rw-r--r--org.eclipse.egit.ui/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.egit.ui/build.properties3
-rw-r--r--org.eclipse.egit.ui/plugin.properties2
-rw-r--r--org.eclipse.egit.ui/plugin.xml26
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIRepositoryUtils.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java29
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWorkspaceActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java65
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/AbstractBranchSelectionDialog.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchRenameDialog.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionAndEditDialog.java57
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java27
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/RenameBranchDialog.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/SimpleConfigureFetchDialog.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPageSource.java20
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java297
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimpleConfigurePushDialog.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogViewContentProvider.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewLabelProvider.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddToIndexCommand.java27
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteRepositoryConfirmDialog.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java45
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java43
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties9
-rw-r--r--org.eclipse.egit/META-INF/MANIFEST.MF2
119 files changed, 1516 insertions, 600 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java
index 670057ed8a..11451f6497 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java
@@ -16,6 +16,9 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Arrays;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -24,6 +27,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.GitProvider;
import org.eclipse.egit.core.IteratorService;
@@ -43,6 +47,10 @@ public class LinkedResourcesTest {
File project2Dir;
+ File otherFolder;
+
+ File rootFile;
+
TestRepository repository1;
TestRepository repository2;
@@ -63,14 +71,27 @@ public class LinkedResourcesTest {
public void setUp() throws Exception {
testUtils = new TestUtils();
// Create first repo and project
- project1 = testUtils.createProjectInLocalFileSystem(project1Name);
+ File rootDir = testUtils.createTempDir("FirstRepository");
+ project1 = testUtils.createProjectInLocalFileSystem(rootDir,
+ project1Name);
project1Dir = project1.getRawLocation().toFile();
- repository1 = new TestRepository(new File(project1Dir,
+ otherFolder = new File(rootDir, "other_folder");
+ assertTrue(otherFolder.mkdirs());
+ File otherFile = new File(otherFolder, "otherFile.txt");
+ rootFile = new File(rootDir, "rootFile.txt");
+ Files.write(otherFile.toPath(),
+ Arrays.<String> asList("Hello", "otherFile"),
+ Charset.defaultCharset());
+ Files.write(rootFile.toPath(), Arrays.<String> asList("Hi", "rootFile"),
+ Charset.defaultCharset());
+ repository1 = new TestRepository(new File(rootDir,
Constants.DOT_GIT));
testUtils.addFileToProject(project1,
"project1folder1/project1folder1file1.txt", "Hello world");
repository1.connect(project1);
repository1.trackAllFiles(project1);
+ repository1.track(otherFile);
+ repository1.track(rootFile);
repository1.commit("Initial commit");
// Create 2nd repo and project
project2 = testUtils.createProjectInLocalFileSystem(project2Name);
@@ -144,6 +165,22 @@ public class LinkedResourcesTest {
}
@Test
+ public void testLinkTargetsInSameRepositoryNotIgnoredByGitResourceDeltaVisitor()
+ throws Exception {
+ IFile file = project1.getFile("link2rootFile");
+ file.createLink(Path.fromOSString(rootFile.getAbsolutePath()), 0, null);
+ IFolder folder = project1.getFolder("link2otherFolder");
+ folder.createLink(Path.fromOSString(otherFolder.getAbsolutePath()), 0,
+ null);
+ project1.refreshLocal(IResource.DEPTH_INFINITE, null);
+ project1.getFile("link2rootFile").touch(null);
+ project1.getFile("link2otherFolder/otherFile.txt").touch(null);
+ resourceDeltaTestHelper1.assertChangedResources(
+ new String[] { "/project1/.project", "/project1/link2rootFile",
+ "/project1/link2otherFolder/otherFile.txt" });
+ }
+
+ @Test
public void testLinkedResourcesIgnoredByIteratorService() throws Exception {
// Create linked folder in project1 that points to project2
IFolder folder = project1.getFolder("link2project2");
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
index 1eccf133f8..af3e9c1605 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
@@ -310,7 +310,7 @@ public class TestRepository {
throws IOException {
RefUpdate updateRef;
updateRef = repository.updateRef(newRefName);
- Ref startRef = repository.getRef(refName);
+ Ref startRef = repository.findRef(refName);
ObjectId startAt = repository.resolve(refName);
String startBranch;
if (startRef != null)
@@ -462,7 +462,7 @@ public class TestRepository {
if (dc == null)
return true;
- Ref ref = repository.getRef(Constants.HEAD);
+ Ref ref = repository.exactRef(Constants.HEAD);
try (RevWalk rw = new RevWalk(repository)) {
RevCommit c = rw.parseCommit(ref.getObjectId());
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RebaseOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RebaseOperationTest.java
index 478a76107a..830a09adf2 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RebaseOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/RebaseOperationTest.java
@@ -82,9 +82,8 @@ public class RebaseOperationTest extends GitTestCase {
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
- RebaseOperation op = new RebaseOperation(
- testRepository.getRepository(), testRepository.getRepository()
- .getRef(MASTER));
+ RebaseOperation op = new RebaseOperation(testRepository.getRepository(),
+ testRepository.getRepository().exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
@@ -127,9 +126,8 @@ public class RebaseOperationTest extends GitTestCase {
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
- RebaseOperation op = new RebaseOperation(
- testRepository.getRepository(), testRepository.getRepository()
- .getRef(MASTER));
+ RebaseOperation op = new RebaseOperation(testRepository.getRepository(),
+ testRepository.getRepository().exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
@@ -172,9 +170,8 @@ public class RebaseOperationTest extends GitTestCase {
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
- RebaseOperation op = new RebaseOperation(
- testRepository.getRepository(), testRepository.getRepository()
- .getRef(MASTER));
+ RebaseOperation op = new RebaseOperation(testRepository.getRepository(),
+ testRepository.getRepository().exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
@@ -220,8 +217,8 @@ public class RebaseOperationTest extends GitTestCase {
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
- RebaseOperation op = new RebaseOperation(repository, repository
- .getRef(MASTER));
+ RebaseOperation op = new RebaseOperation(repository,
+ repository.exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
@@ -230,7 +227,7 @@ public class RebaseOperationTest extends GitTestCase {
try {
// let's try to start again, we should get a wrapped
// WrongRepositoryStateException
- op = new RebaseOperation(repository, repository.getRef(MASTER));
+ op = new RebaseOperation(repository, repository.exactRef(MASTER));
op.execute(null);
fail("Expected Exception not thrown");
} catch (CoreException e) {
diff --git a/org.eclipse.egit.core/build.properties b/org.eclipse.egit.core/build.properties
index 03878bbe4d..a5f0c64765 100644
--- a/org.eclipse.egit.core/build.properties
+++ b/org.eclipse.egit.core/build.properties
@@ -5,5 +5,6 @@ bin.includes = META-INF/,\
plugin.xml,\
about.html,\
.options,\
- plugin.properties
-src.includes = about.html \ No newline at end of file
+ plugin.properties,\
+ schema/
+src.includes = about.html
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitProvider.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitProvider.java
index 159822994a..6ceaa75198 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitProvider.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitProvider.java
@@ -11,6 +11,7 @@ package org.eclipse.egit.core;
import java.io.IOException;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.team.IMoveDeleteHook;
import org.eclipse.core.resources.team.ResourceRuleFactory;
@@ -100,7 +101,10 @@ public class GitProvider extends RepositoryProvider {
@Nullable
public synchronized GitProjectData getData() {
if (data == null) {
- data = GitProjectData.get(getProject());
+ IProject project = getProject();
+ if (project != null) {
+ data = GitProjectData.get(project);
+ }
}
return data;
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
index 3f26c19dfc..7b09f70352 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
@@ -208,7 +208,8 @@ public class RepositoryUtil {
if (entry.getNewId().name().equals(commitId)) {
CheckoutEntry checkoutEntry = entry.parseCheckout();
if (checkoutEntry != null) {
- Ref ref = repository.getRef(checkoutEntry.getToBranch());
+ Ref ref = repository
+ .findRef(checkoutEntry.getToBranch());
if (ref != null) {
ObjectId objectId = ref.getObjectId();
if (objectId != null && objectId.getName()
@@ -582,7 +583,7 @@ public class RepositoryUtil {
* @throws IOException
*/
public String getShortBranch(Repository repository) throws IOException {
- Ref head = repository.getRef(Constants.HEAD);
+ Ref head = repository.exactRef(Constants.HEAD);
if (head == null) {
return CoreText.RepositoryUtil_noHead;
}
@@ -616,7 +617,7 @@ public class RepositoryUtil {
*/
public RevCommit parseHeadCommit(Repository repository) {
try (RevWalk walk = new RevWalk(repository)) {
- Ref head = repository.getRef(Constants.HEAD);
+ Ref head = repository.exactRef(Constants.HEAD);
if (head == null || head.getObjectId() == null)
return null;
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java
index 1c655b2b00..2ae39e064e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java
@@ -24,6 +24,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.core.project.GitProjectData;
@@ -95,9 +96,20 @@ public class GitResourceDeltaVisitor implements IResourceDeltaVisitor {
return true;
}
+ Repository repositoryOfResource = null;
if (resource.isLinked()) {
- // Ignore linked files, folders and their children
- return false;
+ IPath location = resource.getLocation();
+ if (location == null) {
+ return false;
+ }
+ repositoryOfResource = ResourceUtil.getRepository(location);
+ // Ignore linked files, folders and their children, if they're not
+ // in the same repository
+ if (repository != repositoryOfResource) {
+ return false;
+ }
+ } else {
+ repositoryOfResource = ResourceUtil.getRepository(resource);
}
if (resource.getType() == IResource.FOLDER) {
@@ -105,18 +117,18 @@ public class GitResourceDeltaVisitor implements IResourceDeltaVisitor {
if (gitData == null) {
return false;
}
- RepositoryMapping mapping = gitData.getRepositoryMapping(resource);
- if (mapping == null || !gitData.isProtected(resource)
- && mapping.getRepository() != repository) {
+ if (repositoryOfResource == null || !gitData.isProtected(resource)
+ && repositoryOfResource != repository) {
return false;
}
if (delta.getKind() == IResourceDelta.ADDED) {
- String repoRelativePath = mapping.getRepoRelativePath(resource);
+ IPath repoRelativePath = ResourceUtil.getRepositoryRelativePath(
+ resource.getLocation(), repository);
if (repoRelativePath == null) {
return false;
}
if (!repoRelativePath.isEmpty()) {
- String path = repoRelativePath + "/"; //$NON-NLS-1$
+ String path = repoRelativePath.toPortableString() + "/"; //$NON-NLS-1$
if (isIgnoredInOldIndex(path)) {
return true; // keep going to catch .gitignore files.
}
@@ -129,8 +141,7 @@ public class GitResourceDeltaVisitor implements IResourceDeltaVisitor {
return true;
}
- RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
- if (mapping == null || mapping.getRepository() != repository) {
+ if (repositoryOfResource != repository) {
return false;
}
@@ -147,19 +158,21 @@ public class GitResourceDeltaVisitor implements IResourceDeltaVisitor {
return false;
}
- String repoRelativePath = mapping.getRepoRelativePath(resource);
+ IPath repoRelativePath = ResourceUtil
+ .getRepositoryRelativePath(resource.getLocation(), repository);
if (repoRelativePath == null) {
resourcesToUpdate.add(resource);
return true;
}
- if (isIgnoredInOldIndex(repoRelativePath)) {
+ String path = repoRelativePath.toPortableString();
+ if (isIgnoredInOldIndex(path)) {
// This file is ignored in the old index, and ignore rules did not
// change: ignore the delta to avoid unnecessary index updates
return false;
}
- filesToUpdate.add(repoRelativePath);
+ filesToUpdate.add(path);
resourcesToUpdate.add(resource);
return true;
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java
index dc17a1d2f4..b81aec19fa 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java
@@ -716,11 +716,38 @@ public class ResourceUtil {
*/
@Nullable
public static Repository getRepository(@NonNull IPath path) {
- RepositoryMapping mapping = RepositoryMapping.getMapping(path);
- if (mapping != null) {
- return mapping.getRepository();
- }
return Activator.getDefault().getRepositoryCache().getRepository(path);
}
+ /**
+ * Makes a given path relative to the working directory of the given
+ * repository. If the repository is bare or the path is {@code null} or is
+ * not in that working directory, {@code null} is returned. Returns an empty
+ * path if the given path <em>is</em> the working directory.
+ *
+ * @param path
+ * to make relative
+ * @param repository
+ * to make the path relative to
+ * @return the repository-relative path, or {@code null} if the path is not
+ * inside the repository's working directory.
+ */
+ @Nullable
+ public static IPath getRepositoryRelativePath(@Nullable IPath path,
+ @NonNull Repository repository) {
+ if (path == null || repository.isBare()) {
+ return null;
+ }
+ java.nio.file.Path workingDirectory = repository.getWorkTree().toPath();
+ java.nio.file.Path toRelativize = path.toFile().toPath();
+ if (toRelativize.startsWith(workingDirectory)) {
+ int n = workingDirectory.getNameCount();
+ int m = toRelativize.getNameCount();
+ if (n == m) {
+ return new Path(""); //$NON-NLS-1$
+ }
+ return Path.fromOSString(toRelativize.subpath(n, m).toString());
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
index 4ac4f0d8ba..0b8a79a17c 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
@@ -101,8 +101,9 @@ public class AddToIndexOperation implements IEGitOperation {
AddCommand command = addCommands.get(map);
if (command == null) {
Repository repo = map.getRepository();
- Git git = new Git(repo);
- command = git.add();
+ try (Git git = new Git(repo)) {
+ command = git.add();
+ }
addCommands.put(map, command);
}
String filepattern = map.getRepoRelativePath(resource);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java
index 9caf7cdd24..81f7040712 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java
@@ -104,6 +104,37 @@ public class BranchOperation extends BaseOperation {
SubMonitor progress = SubMonitor.convert(pm, 4);
preExecute(progress.newChild(1));
+ closeProjectsMissingAfterCheckout(progress);
+
+ try (Git git = new Git(repository)) {
+ CheckoutCommand co = git.checkout();
+ co.setName(target);
+
+ try {
+ co.call();
+ } catch (CheckoutConflictException e) {
+ return;
+ } catch (JGitInternalException e) {
+ throw new CoreException(
+ Activator.error(e.getMessage(), e));
+ } catch (GitAPIException e) {
+ throw new CoreException(
+ Activator.error(e.getMessage(), e));
+ } finally {
+ result = co.getResult();
+ }
+ if (result.getStatus() == Status.NONDELETED) {
+ retryDelete(result.getUndeletedList());
+ }
+ progress.worked(1);
+ refreshAffectedProjects(progress);
+
+ postExecute(progress.newChild(1));
+ }
+ }
+
+ private void closeProjectsMissingAfterCheckout(SubMonitor progress)
+ throws CoreException {
IProject[] missing = getMissingProjects(target, ProjectUtil
.getValidOpenProjects(repository));
@@ -121,35 +152,18 @@ public class BranchOperation extends BaseOperation {
project.close(closeMonitor.newChild(1));
}
}
+ }
- CheckoutCommand co = new Git(repository).checkout();
- co.setName(target);
-
- try {
- co.call();
- } catch (CheckoutConflictException e) {
- return;
- } catch (JGitInternalException e) {
- throw new CoreException(Activator.error(e.getMessage(), e));
- } catch (GitAPIException e) {
- throw new CoreException(Activator.error(e.getMessage(), e));
- } finally {
- BranchOperation.this.result = co.getResult();
- }
- if (result.getStatus() == Status.NONDELETED)
- retryDelete(result.getUndeletedList());
- progress.worked(1);
-
+ private void refreshAffectedProjects(SubMonitor progress)
+ throws CoreException {
List<String> pathsToHandle = new ArrayList<String>();
- pathsToHandle.addAll(co.getResult().getModifiedList());
- pathsToHandle.addAll(co.getResult().getRemovedList());
- pathsToHandle.addAll(co.getResult().getConflictList());
+ pathsToHandle.addAll(result.getModifiedList());
+ pathsToHandle.addAll(result.getRemovedList());
+ pathsToHandle.addAll(result.getConflictList());
IProject[] refreshProjects = ProjectUtil
.getProjectsContaining(repository, pathsToHandle);
ProjectUtil.refreshValidProjects(refreshProjects, delete,
progress.newChild(1));
-
- postExecute(progress.newChild(1));
}
};
// lock workspace to protect working tree changes
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CherryPickOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CherryPickOperation.java
index 734fc23dac..b37a0ed6ec 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CherryPickOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CherryPickOperation.java
@@ -74,14 +74,14 @@ public class CherryPickOperation implements IEGitOperation {
progress.subTask(MessageFormat.format(
CoreText.CherryPickOperation_cherryPicking,
commit.name()));
- CherryPickCommand command = new Git(repo).cherryPick().include(
- commit.getId());
- MergeStrategy strategy = Activator.getDefault()
- .getPreferredMergeStrategy();
- if (strategy != null) {
- command.setStrategy(strategy);
- }
- try {
+ try (Git git = new Git(repo)) {
+ CherryPickCommand command = git.cherryPick()
+ .include(commit.getId());
+ MergeStrategy strategy = Activator.getDefault()
+ .getPreferredMergeStrategy();
+ if (strategy != null) {
+ command.setStrategy(strategy);
+ }
result = command.call();
} catch (GitAPIException e) {
throw new TeamException(e.getLocalizedMessage(),
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CommitOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CommitOperation.java
index 378b2634b4..ca49fc6628 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CommitOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CommitOperation.java
@@ -210,21 +210,23 @@ public class CommitOperation implements IEGitOperation {
}
private void addUntracked() throws CoreException {
- if (notTracked == null || notTracked.size() == 0)
+ if (notTracked == null || notTracked.size() == 0) {
return;
- AddCommand addCommand = new Git(repo).add();
- boolean fileAdded = false;
- for (String path : notTracked)
- if (commitFileList.contains(path)) {
- addCommand.addFilepattern(path);
- fileAdded = true;
- }
- if (fileAdded)
- try {
+ }
+ try (Git git = new Git(repo)) {
+ AddCommand addCommand = git.add();
+ boolean fileAdded = false;
+ for (String path : notTracked)
+ if (commitFileList.contains(path)) {
+ addCommand.addFilepattern(path);
+ fileAdded = true;
+ }
+ if (fileAdded) {
addCommand.call();
- } catch (Exception e) {
- throw new CoreException(Activator.error(e.getMessage(), e));
}
+ } catch (GitAPIException e) {
+ throw new CoreException(Activator.error(e.getMessage(), e));
+ }
}
@Override
@@ -233,8 +235,7 @@ public class CommitOperation implements IEGitOperation {
}
private void commit() throws TeamException {
- Git git = new Git(repo);
- try {
+ try (Git git = new Git(repo)) {
CommitCommand commitCommand = git.commit();
setAuthorAndCommitter(commitCommand);
commitCommand.setAmend(amending)
@@ -283,9 +284,7 @@ public class CommitOperation implements IEGitOperation {
// TODO: can the commit message be change by the user in case of a merge commit?
private void commitAll() throws TeamException {
-
- Git git = new Git(repo);
- try {
+ try (Git git = new Git(repo)) {
CommitCommand commitCommand = git.commit();
setAuthorAndCommitter(commitCommand);
commit = commitCommand.setAll(true).setMessage(message)
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureFetchAfterCloneTask.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureFetchAfterCloneTask.java
index 06cf9ea758..2bb6bce63d 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureFetchAfterCloneTask.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureFetchAfterCloneTask.java
@@ -45,23 +45,21 @@ public class ConfigureFetchAfterCloneTask implements PostCloneTask {
@Override
public void execute(Repository repository, IProgressMonitor monitor)
throws CoreException {
- try {
- RemoteConfig configToUse = new RemoteConfig(
- repository.getConfig(), remoteName);
- if (fetchRefSpec != null)
+ try (Git git = new Git(repository)) {
+ RemoteConfig configToUse = new RemoteConfig(repository.getConfig(),
+ remoteName);
+ if (fetchRefSpec != null) {
configToUse.addFetchRefSpec(new RefSpec(fetchRefSpec));
+ }
configToUse.update(repository.getConfig());
repository.getConfig().save();
- Git git = new Git(repository);
- try {
- git.fetch().setRemote(remoteName).call();
- } catch (Exception e) {
- Activator.logError(NLS.bind(CoreText.ConfigureFetchAfterCloneTask_couldNotFetch, fetchRefSpec), e);
- }
+ git.fetch().setRemote(remoteName).call();
} catch (Exception e) {
+ Activator.logError(NLS.bind(
+ CoreText.ConfigureFetchAfterCloneTask_couldNotFetch,
+ fetchRefSpec), e);
throw new CoreException(Activator.error(e.getMessage(), e));
}
-
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java
index 579e6ff796..62eb62dc98 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java
@@ -162,8 +162,8 @@ public class ConfigureGerritAfterCloneTask implements PostCloneTask {
if (HTTPS.equals(s) && (u.getPort() == 443 || u.getPort() == -1)
&& path != null && path.startsWith(GERRIT_CONTEXT_ROOT)) {
return true;
- } else
- if (SSH.equals(s) && u.getPort() == GERRIT_SSHD_DEFAULT_PORT) {
+ } else if (SSH.equals(s)
+ && u.getPort() == GERRIT_SSHD_DEFAULT_PORT) {
return true;
}
}
@@ -172,52 +172,45 @@ public class ConfigureGerritAfterCloneTask implements PostCloneTask {
String baseURL = u.setPath("/").toString(); //$NON-NLS-1$
baseURL = baseURL.substring(0, baseURL.length() - 1);
String tmpPath = ""; //$NON-NLS-1$
- HttpURLConnection httpConnection = null;
- try {
- int slash = 1;
- while (true) {
- InputStream in = null;
- try {
- httpConnection = (HttpURLConnection) new URL(baseURL
- + tmpPath + GERRIT_CONFIG_SERVER_VERSION_API)
- .openConnection();
- NetUtil.setSslVerification(repo, httpConnection);
- httpConnection.setRequestMethod("GET"); //$NON-NLS-1$
- httpConnection.setReadTimeout(1000 * timeout);
- int responseCode = httpConnection.getResponseCode();
- switch (responseCode) {
- case HttpURLConnection.HTTP_OK:
- in = httpConnection.getInputStream();
+ int slash = 1;
+ while (true) {
+ HttpURLConnection httpConnection = null;
+ try {
+ httpConnection = (HttpURLConnection) new URL(baseURL
+ + tmpPath + GERRIT_CONFIG_SERVER_VERSION_API)
+ .openConnection();
+ NetUtil.setSslVerification(repo, httpConnection);
+ httpConnection.setRequestMethod("GET"); //$NON-NLS-1$
+ httpConnection.setReadTimeout(1000 * timeout);
+ int responseCode = httpConnection.getResponseCode();
+ switch (responseCode) {
+ case HttpURLConnection.HTTP_OK:
+ try (InputStream in = httpConnection.getInputStream()) {
String response = readFully(in, "UTF-8"); //$NON-NLS-1$
- if (response.startsWith(GERRIT_XSSI_MAGIC_STRING)) {
- return true;
- } else {
- return false;
- }
- case HttpURLConnection.HTTP_NOT_FOUND:
- if (slash > path.length()) {
- return false;
- }
- slash = path.indexOf('/', slash);
- if (slash == -1) {
- // try the entire path
- slash = path.length();
- }
- tmpPath = path.substring(0, slash);
- slash++;
- break;
- default:
+ return response
+ .startsWith(GERRIT_XSSI_MAGIC_STRING);
+ }
+ case HttpURLConnection.HTTP_NOT_FOUND:
+ if (slash > path.length()) {
return false;
}
- } finally {
- if (in != null) {
- in.close();
+ slash = path.indexOf('/', slash);
+ if (slash == -1) {
+ // try the entire path
+ slash = path.length();
}
+ tmpPath = path.substring(0, slash);
+ slash++;
+ break;
+ default:
+ return false;
+ }
+ } catch (IOException e) {
+ return false;
+ } finally {
+ if (httpConnection != null) {
+ httpConnection.disconnect();
}
- }
- } finally {
- if (httpConnection != null) {
- httpConnection.disconnect();
}
}
} else if (SSH.equals(s)) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java
index 02cb9c9e50..e536ab9964 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreateLocalBranchOperation.java
@@ -95,8 +95,7 @@ public class CreateLocalBranchOperation implements IEGitOperation {
CoreText.CreateLocalBranchOperation_CreatingBranchMessage,
name);
actMonitor.beginTask(taskName, 1);
- Git git = new Git(repository);
- try {
+ try (Git git = new Git(repository)) {
if (ref != null) {
SetupUpstreamMode mode;
if (upstreamConfig == UpstreamConfig.NONE)
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DeleteBranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DeleteBranchOperation.java
index a90a653765..fcd0db5729 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DeleteBranchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DeleteBranchOperation.java
@@ -122,8 +122,8 @@ public class DeleteBranchOperation implements IEGitOperation {
}
actMonitor.beginTask(taskName, branches.size());
for (Ref branch : branches) {
- try {
- new Git(repository).branchDelete().setBranchNames(
+ try (Git git = new Git(repository)) {
+ git.branchDelete().setBranchNames(
branch.getName()).setForce(force).call();
status = OK;
} catch (NotMergedException e) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java
index 9a0c451c6e..46508b2fed 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java
@@ -187,18 +187,23 @@ public class DiscardChangesOperation implements IEGitOperation {
private void discardChanges(Repository repository, Collection<String> paths)
throws GitAPIException {
ResourceUtil.saveLocalHistory(repository);
- CheckoutCommand checkoutCommand = new Git(repository).checkout();
- if (revision != null)
- checkoutCommand.setStartPoint(revision);
- if (stage != null)
- checkoutCommand.setStage(stage.checkoutStage);
- if (paths.isEmpty() || paths.contains("")) //$NON-NLS-1$
- checkoutCommand.setAllPaths(true);
- else {
- for (String path : paths)
- checkoutCommand.addPath(path);
+ try (Git git = new Git(repository)) {
+ CheckoutCommand checkoutCommand = git.checkout();
+ if (revision != null) {
+ checkoutCommand.setStartPoint(revision);
+ }
+ if (stage != null) {
+ checkoutCommand.setStage(stage.checkoutStage);
+ }
+ if (paths.isEmpty() || paths.contains("")) { //$NON-NLS-1$
+ checkoutCommand.setAllPaths(true);
+ } else {
+ for (String path : paths) {
+ checkoutCommand.addPath(path);
+ }
+ }
+ checkoutCommand.call();
}
- checkoutCommand.call();
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/EditCommitOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/EditCommitOperation.java
index 5ff4e7f84e..1c1d3f9eb8 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/EditCommitOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/EditCommitOperation.java
@@ -89,8 +89,7 @@ public class EditCommitOperation implements IEGitOperation {
return oldMessage;
}
};
- try {
- Git git = new Git(repository);
+ try (Git git = new Git(repository)) {
git.rebase().setUpstream(commit.getParent(0))
.runInteractively(handler)
.setOperation(RebaseCommand.Operation.BEGIN).call();
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java
index feaef70de9..db82ffdedf 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/FetchOperation.java
@@ -120,23 +120,26 @@ public class FetchOperation {
actMonitor = new NullProgressMonitor();
EclipseGitProgressTransformer gitMonitor = new EclipseGitProgressTransformer(
actMonitor);
- FetchCommand command;
- if (rc == null)
- command = new Git(repository).fetch().setRemote(
- uri.toPrivateString()).setRefSpecs(specs);
- else
- command = new Git(repository).fetch().setRemote(rc.getName());
- command.setCredentialsProvider(credentialsProvider).setTimeout(timeout)
- .setDryRun(dryRun).setProgressMonitor(gitMonitor);
- if (tagOpt != null)
- command.setTagOpt(tagOpt);
- try {
- operationResult = command.call();
- } catch (JGitInternalException e) {
- throw new InvocationTargetException(e.getCause() != null ? e
- .getCause() : e);
- } catch (Exception e) {
- throw new InvocationTargetException(e);
+ try (Git git = new Git(repository)) {
+ FetchCommand command;
+ if (rc == null)
+ command = git.fetch().setRemote(uri.toPrivateString())
+ .setRefSpecs(specs);
+ else
+ command = git.fetch().setRemote(rc.getName());
+ command.setCredentialsProvider(credentialsProvider)
+ .setTimeout(timeout).setDryRun(dryRun)
+ .setProgressMonitor(gitMonitor);
+ if (tagOpt != null)
+ command.setTagOpt(tagOpt);
+ try {
+ operationResult = command.call();
+ } catch (JGitInternalException e) {
+ throw new InvocationTargetException(
+ e.getCause() != null ? e.getCause() : e);
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/GarbageCollectOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/GarbageCollectOperation.java
index eac528c21f..71af5d3b20 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/GarbageCollectOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/GarbageCollectOperation.java
@@ -39,11 +39,9 @@ public class GarbageCollectOperation implements IEGitOperation {
*/
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
- Git git = new Git(repository);
- EclipseGitProgressTransformer pm = new EclipseGitProgressTransformer(
- monitor);
- try {
- git.gc().setProgressMonitor(pm).call();
+ try (Git git = new Git(repository)) {
+ git.gc().setProgressMonitor(
+ new EclipseGitProgressTransformer(monitor)).call();
} catch (GitAPIException e) {
throw new CoreException(new Status(IStatus.ERROR,
Activator.getPluginId(), e.getMessage(), e));
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ListRemoteOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ListRemoteOperation.java
index 0a6ed323f3..a53c30dbaf 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ListRemoteOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ListRemoteOperation.java
@@ -45,9 +45,10 @@ public class ListRemoteOperation {
*/
public ListRemoteOperation(final Repository localDb, final URIish uri,
int timeout) {
- Git git = new Git(localDb);
- rc = git.lsRemote();
- rc.setRemote(uri.toString()).setTimeout(timeout);
+ try (Git git = new Git(localDb)) {
+ rc = git.lsRemote();
+ rc.setRemote(uri.toString()).setTimeout(timeout);
+ }
}
/**
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/MergeOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/MergeOperation.java
index 055a509f6f..c3487d321c 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/MergeOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/MergeOperation.java
@@ -157,44 +157,54 @@ public class MergeOperation implements IEGitOperation {
IProject[] validProjects = ProjectUtil.getValidOpenProjects(repository);
SubMonitor progress = SubMonitor.convert(mymonitor, NLS.bind(
CoreText.MergeOperation_ProgressMerge, refName), 3);
- Git git = new Git(repository);
- progress.worked(1);
- MergeCommand merge = git.merge()
- .setProgressMonitor(
- new EclipseGitProgressTransformer(progress.newChild(1)));
- try {
- Ref ref = repository.getRef(refName);
- if (ref != null)
+ try (Git git = new Git(repository)) {
+ progress.worked(1);
+ MergeCommand merge = git.merge().setProgressMonitor(
+ new EclipseGitProgressTransformer(
+ progress.newChild(1)));
+ Ref ref = repository.findRef(refName);
+ if (ref != null) {
merge.include(ref);
- else
+ } else {
merge.include(ObjectId.fromString(refName));
- } catch (IOException e) {
- throw new TeamException(CoreText.MergeOperation_InternalError, e);
- }
- if (fastForwardMode != null)
- merge.setFastForward(fastForwardMode);
- if (commit != null)
- merge.setCommit(commit.booleanValue());
- if (squash != null)
- merge.setSquash(squash.booleanValue());
- if (mergeStrategy != null) {
- merge.setStrategy(mergeStrategy);
- }
- if (message != null)
- merge.setMessage(message);
- try {
+ }
+ if (fastForwardMode != null) {
+ merge.setFastForward(fastForwardMode);
+ }
+ if (commit != null) {
+ merge.setCommit(commit.booleanValue());
+ }
+ if (squash != null) {
+ merge.setSquash(squash.booleanValue());
+ }
+ if (mergeStrategy != null) {
+ merge.setStrategy(mergeStrategy);
+ }
+ if (message != null) {
+ merge.setMessage(message);
+ }
mergeResult = merge.call();
- if (MergeResult.MergeStatus.NOT_SUPPORTED.equals(mergeResult.getMergeStatus()))
- throw new TeamException(new Status(IStatus.INFO, Activator.getPluginId(), mergeResult.toString()));
+ if (MergeResult.MergeStatus.NOT_SUPPORTED
+ .equals(mergeResult.getMergeStatus())) {
+ throw new TeamException(new Status(IStatus.INFO,
+ Activator.getPluginId(),
+ mergeResult.toString()));
+ }
+ } catch (IOException e) {
+ throw new TeamException(
+ CoreText.MergeOperation_InternalError, e);
} catch (NoHeadException e) {
- throw new TeamException(CoreText.MergeOperation_MergeFailedNoHead, e);
+ throw new TeamException(
+ CoreText.MergeOperation_MergeFailedNoHead, e);
} catch (ConcurrentRefUpdateException e) {
- throw new TeamException(CoreText.MergeOperation_MergeFailedRefUpdate, e);
+ throw new TeamException(
+ CoreText.MergeOperation_MergeFailedRefUpdate, e);
} catch (CheckoutConflictException e) {
mergeResult = new MergeResult(e.getConflictingPaths());
return;
} catch (GitAPIException e) {
- throw new TeamException(e.getLocalizedMessage(), e.getCause());
+ throw new TeamException(e.getLocalizedMessage(),
+ e.getCause());
} finally {
ProjectUtil.refreshValidProjects(validProjects,
progress.newChild(1));
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java
index 2ea4153d8e..f259c27644 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java
@@ -167,9 +167,9 @@ public class PullOperation implements IEGitOperation {
for (int i = 0; i < repositories.length; i++) {
Repository repository = repositories[i];
IProject[] validProjects = ProjectUtil.getValidOpenProjects(repository);
- PullCommand pull = new Git(repository).pull();
PullResult pullResult = null;
- try {
+ try (Git git = new Git(repository)) {
+ PullCommand pull = git.pull();
pull.setProgressMonitor(new EclipseGitProgressTransformer(
progress.newChild(1)));
pull.setTimeout(timeout);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java
index 9c3111d419..fde43dbdfe 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PushOperation.java
@@ -164,11 +164,10 @@ public class PushOperation {
totalWork);
operationResult = new PushOperationResult();
- Git git = new Git(localDb);
-
- if (specification != null)
- for (final URIish uri : specification.getURIs()) {
- if (progress.isCanceled()) {
+ try (Git git = new Git(localDb)) {
+ if (specification != null)
+ for (final URIish uri : specification.getURIs()) {
+ if (progress.isCanceled()) {
operationResult.addOperationResult(uri,
CoreText.PushOperation_resultCancelled);
continue;
@@ -177,15 +176,16 @@ public class PushOperation {
Collection<RemoteRefUpdate> refUpdates = specification
.getRefUpdates(uri);
final EclipseGitProgressTransformer gitSubMonitor = new EclipseGitProgressTransformer(
- progress.newChild(WORK_UNITS_PER_TRANSPORT / 2));
+ progress.newChild(WORK_UNITS_PER_TRANSPORT / 2));
try {
Transport transport = Transport.open(localDb, uri);
transport.setDryRun(dryRun);
transport.setTimeout(timeout);
- if (credentialsProvider != null)
+ if (credentialsProvider != null) {
transport.setCredentialsProvider(
credentialsProvider);
+ }
PushResult result = transport.push(gitSubMonitor,
refUpdates, out);
@@ -204,31 +204,33 @@ public class PushOperation {
handleException(uri, e, e.getMessage());
}
- progress.worked(WORK_UNITS_PER_TRANSPORT / 2);
- }
- else {
- final EclipseGitProgressTransformer gitMonitor = new EclipseGitProgressTransformer(
- progress.newChild(totalWork));
- try {
- Iterable<PushResult> results = git.push().setRemote(remoteName)
- .setDryRun(dryRun).setTimeout(timeout)
- .setProgressMonitor(gitMonitor)
- .setCredentialsProvider(credentialsProvider)
- .setOutputStream(out).call();
- for (PushResult result : results) {
- operationResult.addOperationResult(result.getURI(), result);
+ progress.worked(WORK_UNITS_PER_TRANSPORT / 2);
+ }
+ else {
+ final EclipseGitProgressTransformer gitMonitor = new EclipseGitProgressTransformer(
+ progress.newChild(totalWork));
+ try {
+ Iterable<PushResult> results = git.push()
+ .setRemote(remoteName).setDryRun(dryRun)
+ .setTimeout(timeout).setProgressMonitor(gitMonitor)
+ .setCredentialsProvider(credentialsProvider)
+ .setOutputStream(out).call();
+ for (PushResult result : results) {
+ operationResult.addOperationResult(result.getURI(),
+ result);
+ }
+ } catch (JGitInternalException e) {
+ String errorMessage = e.getCause() != null
+ ? e.getCause().getMessage() : e.getMessage();
+ String userMessage = NLS.bind(
+ CoreText.PushOperation_InternalExceptionOccurredMessage,
+ errorMessage);
+ URIish uri = getPushURIForErrorHandling();
+ handleException(uri, e, userMessage);
+ } catch (Exception e) {
+ URIish uri = getPushURIForErrorHandling();
+ handleException(uri, e, e.getMessage());
}
- } catch (JGitInternalException e) {
- String errorMessage = e.getCause() != null ? e.getCause()
- .getMessage() : e.getMessage();
- String userMessage = NLS.bind(
- CoreText.PushOperation_InternalExceptionOccurredMessage,
- errorMessage);
- URIish uri = getPushURIForErrorHandling();
- handleException(uri, e, userMessage);
- } catch (Exception e) {
- URIish uri = getPushURIForErrorHandling();
- handleException(uri, e, e.getMessage());
}
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RebaseOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RebaseOperation.java
index 86d5135a65..d0d37e372e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RebaseOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RebaseOperation.java
@@ -136,15 +136,15 @@ public class RebaseOperation implements IEGitOperation {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(actMonitor, 2);
- RebaseCommand cmd = new Git(repository).rebase()
- .setProgressMonitor(
- new EclipseGitProgressTransformer(progress.newChild(1)));
- MergeStrategy strategy = Activator.getDefault()
- .getPreferredMergeStrategy();
- if (strategy != null) {
- cmd.setStrategy(strategy);
- }
- try {
+ try (Git git = new Git(repository)) {
+ RebaseCommand cmd = git.rebase().setProgressMonitor(
+ new EclipseGitProgressTransformer(
+ progress.newChild(1)));
+ MergeStrategy strategy = Activator.getDefault()
+ .getPreferredMergeStrategy();
+ if (strategy != null) {
+ cmd.setStrategy(strategy);
+ }
if (handler != null)
cmd.runInteractively(handler, true);
if (operation == Operation.BEGIN) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java
index 052f0fffdc..29dfca5045 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java
@@ -94,25 +94,28 @@ public class RemoveFromIndexOperation implements IEGitOperation {
private static GitCommand<?> prepareCommand(Repository repository,
Collection<String> paths) {
- Git git = new Git(repository);
- if (hasHead(repository)) {
- ResetCommand resetCommand = git.reset();
- resetCommand.setRef(HEAD);
- for (String path : paths)
- resetCommand.addPath(getCommandPath(path));
- return resetCommand;
- } else {
- RmCommand rmCommand = git.rm();
- rmCommand.setCached(true);
- for (String path : paths)
- rmCommand.addFilepattern(getCommandPath(path));
- return rmCommand;
+ try (Git git = new Git(repository)) {
+ if (hasHead(repository)) {
+ ResetCommand resetCommand = git.reset();
+ resetCommand.setRef(HEAD);
+ for (String path : paths) {
+ resetCommand.addPath(getCommandPath(path));
+ }
+ return resetCommand;
+ } else {
+ RmCommand rmCommand = git.rm();
+ rmCommand.setCached(true);
+ for (String path : paths) {
+ rmCommand.addFilepattern(getCommandPath(path));
+ }
+ return rmCommand;
+ }
}
}
private static boolean hasHead(Repository repository) {
try {
- Ref head = repository.getRef(HEAD);
+ Ref head = repository.exactRef(HEAD);
return head != null && head.getObjectId() != null;
} catch (IOException e) {
return false;
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameBranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameBranchOperation.java
index 3bdcd6e1ae..a7262f8761 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameBranchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameBranchOperation.java
@@ -64,8 +64,8 @@ public class RenameBranchOperation implements IEGitOperation {
CoreText.RenameBranchOperation_TaskName, branch
.getName(), newName);
actMonitor.beginTask(taskName, 1);
- try {
- new Git(repository).branchRename().setOldName(
+ try (Git git = new Git(repository)) {
+ git.branchRename().setOldName(
branch.getName()).setNewName(newName).call();
} catch (JGitInternalException e) {
throw new CoreException(Activator.error(e.getMessage(), e));
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RevertCommitOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RevertCommitOperation.java
index 888336d6cc..211275234f 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RevertCommitOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RevertCommitOperation.java
@@ -87,27 +87,27 @@ public class RevertCommitOperation implements IEGitOperation {
progress.subTask(MessageFormat.format(
CoreText.RevertCommitOperation_reverting,
Integer.valueOf(commits.size())));
- RevertCommand command = new Git(repo).revert();
- MergeStrategy strategy = Activator.getDefault()
- .getPreferredMergeStrategy();
- if (strategy != null) {
- command.setStrategy(strategy);
- }
- for (RevCommit commit : commits)
- command.include(commit);
- try {
+ try (Git git = new Git(repo)) {
+ RevertCommand command = git.revert();
+ MergeStrategy strategy = Activator.getDefault()
+ .getPreferredMergeStrategy();
+ if (strategy != null) {
+ command.setStrategy(strategy);
+ }
+ for (RevCommit commit : commits) {
+ command.include(commit);
+ }
newHead = command.call();
reverted = command.getRevertedRefs();
result = command.getFailingResult();
+ progress.worked(1);
+ ProjectUtil.refreshValidProjects(
+ ProjectUtil.getValidOpenProjects(repo),
+ progress.newChild(1));
} catch (GitAPIException e) {
throw new TeamException(e.getLocalizedMessage(),
e.getCause());
}
- progress.worked(1);
-
- ProjectUtil.refreshValidProjects(
- ProjectUtil.getValidOpenProjects(repo),
- progress.newChild(1));
}
};
ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(),
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RewordCommitOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RewordCommitOperation.java
index 2137932a79..9d69c168f9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RewordCommitOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RewordCommitOperation.java
@@ -92,8 +92,7 @@ public class RewordCommitOperation implements IEGitOperation {
return newMessage;
}
};
- try {
- Git git = new Git(repository);
+ try (Git git = new Git(repository)) {
git.rebase().setUpstream(commit.getParent(0))
.runInteractively(handler)
.setOperation(RebaseCommand.Operation.BEGIN).call();
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/SquashCommitsOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/SquashCommitsOperation.java
index b101627420..05bb941dd3 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/SquashCommitsOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/SquashCommitsOperation.java
@@ -109,8 +109,7 @@ public class SquashCommitsOperation implements IEGitOperation {
return messageHandler.modifyCommitMessage(oldMessage);
}
};
- try {
- Git git = new Git(repository);
+ try (Git git = new Git(repository)) {
RebaseCommand command = git.rebase()
.setUpstream(commits.get(0).getParent(0))
.runInteractively(handler)
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
index 15501e211f..a64361c984 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
@@ -117,7 +117,9 @@ public class RepositoryMapping {
java.nio.file.Path lPath = location.toFile().toPath();
// Require at least one common component for using a relative path
if (lPath.getNameCount() > 0 && gPath.getNameCount() > 0
- && gPath.getRoot().equals(lPath.getRoot())
+ && (gPath.getRoot() == lPath.getRoot()
+ || gPath.getRoot() != null
+ && gPath.getRoot().equals(lPath.getRoot()))
&& gPath.getName(0).equals(lPath.getName(0))) {
gPath = lPath.relativize(gPath);
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparator.java
index e8258a4e5d..642ba7cf62 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparator.java
@@ -39,7 +39,6 @@ class GitResourceVariantComparator implements IResourceVariantComparator {
}
@Override
- @SuppressWarnings("resource")
public boolean compare(IResource local, IResourceVariant remote) {
if (!local.exists() || remote == null) {
return false;
diff --git a/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF
index c9c31c7282..2bba633592 100644
--- a/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.gitflow.ui/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Import-Package: org.eclipse.egit.core;version="[4.4.0,4.5.0)",
org.eclipse.egit.ui.internal.branch;version="[4.4.0,4.5.0)",
org.eclipse.egit.ui.internal.commit;version="[4.4.0,4.5.0)",
org.eclipse.egit.ui.internal.history;version="[4.4.0,4.5.0)",
+ org.eclipse.egit.ui.internal.operations;version="[4.4.0,4.5.0)",
org.eclipse.egit.ui.internal.rebase;version="[4.4.0,4.5.0)",
org.eclipse.egit.ui.internal.repository.tree;version="[4.4.0,4.5.0)",
org.eclipse.egit.ui.internal.selection;version="[4.4.0,4.5.0)",
diff --git a/org.eclipse.egit.gitflow.ui/plugin.properties b/org.eclipse.egit.gitflow.ui/plugin.properties
index ad2241b1d8..996b761bd8 100644
--- a/org.eclipse.egit.gitflow.ui/plugin.properties
+++ b/org.eclipse.egit.gitflow.ui/plugin.properties
@@ -24,4 +24,8 @@ TeamGitFlowHotfixStart.name = Start Hotfix
TeamGitFlowHotfixFinish.name = Finish Hotfix
TeamGitFlowDevelopCheckout.name = Checkout Develop
Decorator_name=Gitflow
-Decorator_description=Shows Gitflow specific information on repository nodes. \ No newline at end of file
+Decorator_description=Shows Gitflow specific information on repository nodes.
+TeamGitFlowDevelopCompare.name=Compare with develop branch
+TeamGitFlowDevelopCompare.label=develop branch
+TeamGitFlowDevelopReplace.name=Replace with develop branch
+TeamGitFlowDevelopReplace.label=develop branch \ No newline at end of file
diff --git a/org.eclipse.egit.gitflow.ui/plugin.xml b/org.eclipse.egit.gitflow.ui/plugin.xml
index 84dd3ceef9..b603ade427 100644
--- a/org.eclipse.egit.gitflow.ui/plugin.xml
+++ b/org.eclipse.egit.gitflow.ui/plugin.xml
@@ -694,4 +694,107 @@
</description>
</decorator>
</extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:replaceWithMenu?after=gitReplaceWithGroup">
+ <command
+ commandId="org.eclipse.egit.gitflow.ui.command.replaceWithDevelop"
+ icon="icons/obj16/git-flow_16x10.png"
+ label="%TeamGitFlowDevelopReplace.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <reference
+ definitionId="org.eclipse.egit.ui.resourcesSingleRepository">
+ </reference>
+ <reference
+ definitionId="org.eclipse.egit.ui.resourcesAllInRepository">
+ </reference>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:compareWithMenu?after=gitCompareWithGroup">
+ <command
+ commandId="org.eclipse.egit.gitflow.ui.command.compareWithDevelop"
+ icon="icons/obj16/git-flow_16x10.png"
+ label="%TeamGitFlowDevelopCompare.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <reference
+ definitionId="org.eclipse.egit.ui.resourcesSingleRepository">
+ </reference>
+ <reference
+ definitionId="org.eclipse.egit.ui.resourcesAllInRepository">
+ </reference>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.egit.gitflow.ui.command.replaceWithDevelop"
+ name="%TeamGitFlowDevelopReplace.name">
+ </command>
+ <command
+ id="org.eclipse.egit.gitflow.ui.command.compareWithDevelop"
+ name="%TeamGitFlowDevelopCompare.name">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ commandId="org.eclipse.egit.gitflow.ui.command.replaceWithDevelop">
+ <class
+ class="org.eclipse.egit.gitflow.ui.internal.actions.DevelopReplaceHandler">
+ </class>
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.egit.gitflow.ui.commandEnabled">
+ </reference>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="org.eclipse.egit.ui.currentRepository">
+ <not>
+ <test
+ forcePluginActivation="true"
+ property="GitFlowRepository.isDevelop">
+ </test>
+ </not>
+
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ commandId="org.eclipse.egit.gitflow.ui.command.compareWithDevelop">
+ <class
+ class="org.eclipse.egit.gitflow.ui.internal.actions.DevelopCompareHandler">
+ </class>
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.egit.gitflow.ui.commandEnabled">
+ </reference>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="org.eclipse.egit.ui.currentRepository">
+ <not>
+ <test
+ forcePluginActivation="true"
+ property="GitFlowRepository.isDevelop">
+ </test>
+ </not>
+
+ </with>
+ </enabledWhen>
+ </handler>
+ </extension>
</plugin>
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopCompareHandler.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopCompareHandler.java
new file mode 100644
index 0000000000..cb9a45a24a
--- /dev/null
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopCompareHandler.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (C) 2016, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.gitflow.ui.internal.actions;
+
+import static org.eclipse.egit.ui.Activator.handleError;
+import static org.eclipse.egit.ui.internal.UIText.CompareWithRefAction_errorOnSynchronize;
+import static org.eclipse.jgit.lib.Constants.HEAD;
+import static org.eclipse.ui.PlatformUI.getWorkbench;
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.egit.gitflow.GitFlowRepository;
+import org.eclipse.egit.ui.internal.CompareUtils;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * Compare content of selected resources with that on develop branch.
+ */
+public class DevelopCompareHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
+
+ IResource[] selectedResources = GitFlowHandlerUtil.gatherResourceToOperateOn(event);
+ String revision;
+ try {
+ revision = GitFlowHandlerUtil.gatherRevision(event);
+ } catch (OperationCanceledException e) {
+ return null;
+ } catch (IOException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ }
+
+ IWorkbenchPage workBenchPage = getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ CompareUtils.compare(selectedResources, gfRepo.getRepository(),
+ HEAD, revision, true, workBenchPage);
+ } catch (IOException e) {
+ handleError(CompareWithRefAction_errorOnSynchronize, e, true);
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopReplaceHandler.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopReplaceHandler.java
new file mode 100644
index 0000000000..3f428611e6
--- /dev/null
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/DevelopReplaceHandler.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (C) 2016, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.gitflow.ui.internal.actions;
+
+import static org.eclipse.core.runtime.Status.OK_STATUS;
+import static org.eclipse.egit.ui.Activator.createErrorStatus;
+import static org.eclipse.egit.ui.JobFamilies.DISCARD_CHANGES;
+import static org.eclipse.egit.ui.internal.UIText.DiscardChangesAction_discardChanges;
+import static org.eclipse.egit.ui.internal.operations.GitScopeUtil.getRelatedChanges;
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.egit.core.op.DiscardChangesOperation;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Replace content of selected resources with that on develop branch.
+ */
+public class DevelopReplaceHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
+
+ final DiscardChangesOperation operation;
+ try {
+ operation = createOperation(part, event);
+ } catch (IOException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ }
+
+ if (operation == null) {
+ return null;
+ }
+ Job job = new WorkspaceJob(DiscardChangesAction_discardChanges) {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) {
+ try {
+ operation.execute(monitor);
+ } catch (CoreException e) {
+ return createErrorStatus(e.getStatus().getMessage(), e);
+ }
+ return OK_STATUS;
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ if (DISCARD_CHANGES.equals(family)) {
+ return true;
+ }
+ return super.belongsTo(family);
+ }
+ };
+ job.setUser(true);
+ job.setRule(operation.getSchedulingRule());
+ job.schedule();
+ return null;
+ }
+
+ private @Nullable DiscardChangesOperation createOperation(
+ IWorkbenchPart part, ExecutionEvent event)
+ throws ExecutionException, IOException {
+ IResource[] selectedResources = GitFlowHandlerUtil.gatherResourceToOperateOn(event);
+ String revision;
+ try {
+ revision = GitFlowHandlerUtil.gatherRevision(event);
+ } catch (OperationCanceledException e) {
+ return null;
+ }
+
+ IResource[] resourcesInScope;
+ try {
+ resourcesInScope = getRelatedChanges(part, selectedResources);
+ } catch (InterruptedException e) {
+ // ignore, we will not discard the files in case the user
+ // cancels the scope operation
+ return null;
+ }
+
+ return new DiscardChangesOperation(resourcesInScope, revision);
+ }
+}
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/GitFlowHandlerUtil.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/GitFlowHandlerUtil.java
index d0f587c2cf..fbea95702b 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/GitFlowHandlerUtil.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/GitFlowHandlerUtil.java
@@ -8,12 +8,18 @@
*******************************************************************************/
package org.eclipse.egit.gitflow.ui.internal.actions;
+import java.io.IOException;
+
import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.resources.IResource;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.ui.internal.selection.SelectionUtils;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -39,4 +45,35 @@ public class GitFlowHandlerUtil {
return new GitFlowRepository(repository);
}
+ static IResource[] gatherResourceToOperateOn(ExecutionEvent event) {
+ return getSelectedResources(event);
+ }
+
+ static IResource[] getSelectedResources(ExecutionEvent event) {
+ IStructuredSelection selection = getSelection(event);
+ return SelectionUtils.getSelectedResources(selection);
+ }
+
+ static IStructuredSelection getSelection(ExecutionEvent event) {
+ if (event == null) {
+ throw new IllegalArgumentException("event must not be NULL"); //$NON-NLS-1$
+ }
+ Object context = event.getApplicationContext();
+ if (context instanceof IEvaluationContext) {
+ return SelectionUtils.getSelection((IEvaluationContext) context);
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ static String gatherRevision(ExecutionEvent event) throws IOException {
+ final GitFlowRepository gfRepo = GitFlowHandlerUtil
+ .getRepository(event);
+ Ref develop = gfRepo.getRepository()
+ .exactRef(gfRepo.getConfig().getDevelopFull());
+ if (develop == null) {
+ throw new IllegalStateException(
+ "Gitflow command called on non-Gitflow repository"); //$NON-NLS-1$
+ }
+ return develop.getName();
+ }
}
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/DecoratedBranchLabelProvider.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/DecoratedBranchLabelProvider.java
new file mode 100644
index 0000000000..597a4463a7
--- /dev/null
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/DecoratedBranchLabelProvider.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (C) 2016, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.gitflow.ui.internal.dialogs;
+
+import java.io.IOException;
+
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.internal.UIIcons;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swt.graphics.Image;
+
+class DecoratedBranchLabelProvider extends ColumnLabelProvider {
+ private ResourceManager resourceManager = Activator.getDefault().getResourceManager();
+
+ private Repository repository;
+
+ private String prefix;
+
+ public DecoratedBranchLabelProvider(Repository repository, String prefix) {
+ this.repository = repository;
+ this.prefix = prefix;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof Ref) {
+ String name = ((Ref) element).getName();
+ return name.substring(prefix.length());
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof Ref) {
+ return decorateImage((Ref) element);
+ }
+ return super.getImage(element);
+ }
+
+ private Image decorateImage(Ref node) {
+ String refName = node.getName();
+
+ String branchName;
+ String compareString;
+
+ try {
+ branchName = repository.getFullBranch();
+ compareString = refName;
+ } catch (IOException e) {
+ return UIIcons.getImage(resourceManager, UIIcons.BRANCH);
+ }
+
+ if (compareString.equals(branchName)) {
+ return UIIcons.getImage(resourceManager, UIIcons.CHECKED_OUT_BRANCH);
+ } else {
+ return UIIcons.getImage(resourceManager, UIIcons.BRANCH);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FeatureBranchSelectionDialog.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FeatureBranchSelectionDialog.java
index 0120fb707a..e99a27f821 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FeatureBranchSelectionDialog.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FeatureBranchSelectionDialog.java
@@ -11,10 +11,12 @@ package org.eclipse.egit.gitflow.ui.internal.dialogs;
import static org.eclipse.jface.dialogs.IDialogConstants.CANCEL_LABEL;
import static org.eclipse.jface.dialogs.IDialogConstants.OK_LABEL;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.egit.gitflow.GitFlowRepository;
+import org.eclipse.egit.gitflow.ui.Activator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -22,6 +24,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
@@ -32,6 +35,7 @@ import org.eclipse.swt.widgets.Shell;
public class FeatureBranchSelectionDialog extends MessageDialog {
private List<Ref> selected = new ArrayList<>();
private FilteredBranchesWidget filteredFeatures;
+ private GitFlowRepository gfRepo;
/**
* @param parentShell
@@ -46,6 +50,7 @@ public class FeatureBranchSelectionDialog extends MessageDialog {
String featurePrefix, GitFlowRepository gfRepo) {
super(parentShell, title, null, message, MessageDialog.QUESTION,
new String[] { OK_LABEL, CANCEL_LABEL }, 0);
+ this.gfRepo = gfRepo;
filteredFeatures = new FilteredBranchesWidget(refs, featurePrefix, gfRepo);
}
@@ -70,7 +75,9 @@ public class FeatureBranchSelectionDialog extends MessageDialog {
@Override
public void doubleClick(DoubleClickEvent event) {
- buttonPressed(OK);
+ if (getButton(OK).isEnabled()) {
+ buttonPressed(OK);
+ }
}
});
return result;
@@ -101,6 +108,17 @@ public class FeatureBranchSelectionDialog extends MessageDialog {
}
private void checkPage() {
- getButton(OK).setEnabled(!filteredFeatures.getSelection().isEmpty());
+ List<Ref> selection = filteredFeatures.getSelection();
+ if (selection.isEmpty() || selection.get(0) == null) {
+ getButton(OK).setEnabled(false);
+ return;
+ }
+ Repository repository = gfRepo.getRepository();
+ try {
+ Ref currentBranch = repository.exactRef(repository.getFullBranch());
+ getButton(OK).setEnabled(!selection.get(0).equals(currentBranch));
+ } catch (IOException e) {
+ Activator.logError("Unable to find current branch", e); //$NON-NLS-1$
+ }
}
}
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java
index 6eb6f1b7d1..7ef1ed2245 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java
@@ -14,9 +14,9 @@ import java.util.List;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.gitflow.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
@@ -27,7 +27,6 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -83,9 +82,11 @@ public class FilteredBranchesWidget {
branchesViewer.getTree().setLinesVisible(false);
branchesViewer.getTree().setHeaderVisible(true);
- TreeColumn nameColumn = createColumn(UIText.BranchSelectionTree_NameColumn, branchesViewer, createNameLabelProvider());
+ TreeColumn nameColumn = createColumn(
+ UIText.BranchSelectionTree_NameColumn, branchesViewer,
+ new DecoratedBranchLabelProvider(gfRepo.getRepository(), prefix));
TreeColumn idColumn = createColumn(UIText.BranchSelectionTree_IdColumn, branchesViewer, new ColumnLabelProvider() {
-
+
@Override
public String getText(Object element) {
if (element instanceof Ref) {
@@ -98,7 +99,7 @@ public class FilteredBranchesWidget {
return super.getText(element);
}});
TreeColumn msgColumn = createColumn(UIText.BranchSelectionTree_MessageColumn, branchesViewer, new ColumnLabelProvider() {
-
+
@Override
public String getText(Object element) {
if (element instanceof Ref) {
@@ -145,29 +146,9 @@ public class FilteredBranchesWidget {
};
}
- private ColumnLabelProvider createNameLabelProvider() {
- return new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- if (element instanceof Ref) {
- String name = ((Ref) element).getName();
- return name.substring(prefix.length());
- }
- return super.getText(element);
- }
-
- @Override
- public Image getImage(Object element) {
- return RepositoryTreeNodeType.REF.getIcon();
- }
-
- };
- }
-
@SuppressWarnings("unchecked") // conversion to conform to List<Ref>
List<Ref> getSelection() {
- return branchesViewer.getStructuredSelection().toList();
+ return ((IStructuredSelection) branchesViewer.getSelection()).toList();
}
TreeViewer getBranchesList() {
diff --git a/org.eclipse.egit.gitflow/META-INF/MANIFEST.MF b/org.eclipse.egit.gitflow/META-INF/MANIFEST.MF
index 0a948546c5..cd202c0e6a 100644
--- a/org.eclipse.egit.gitflow/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.gitflow/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin_name
-Bundle-SymbolicName: org.eclipse.egit.gitflow
+Bundle-SymbolicName: org.eclipse.egit.gitflow;singleton:=true
Bundle-Version: 4.4.0.qualifier
Bundle-Vendor: %provider_name
Bundle-Activator: org.eclipse.egit.gitflow.Activator
diff --git a/org.eclipse.egit.repository/pom.xml b/org.eclipse.egit.repository/pom.xml
index 79fba0ff2a..2408ee7d33 100644
--- a/org.eclipse.egit.repository/pom.xml
+++ b/org.eclipse.egit.repository/pom.xml
@@ -134,7 +134,7 @@
<layout>p2</layout>
</repository>
<repository>
- <url>http://download.eclipse.org/releases/staging</url>
+ <url>http://download.eclipse.org/staging/neon/</url>
<layout>p2</layout>
</repository>
</repositories>
diff --git a/org.eclipse.egit.target/egit-4.6-staging.target b/org.eclipse.egit.target/egit-4.6-staging.target
index 71c9849f1c..3082cba2a8 100644
--- a/org.eclipse.egit.target/egit-4.6-staging.target
+++ b/org.eclipse.egit.target/egit-4.6-staging.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
-<target name="egit-4.6-staging" sequenceNumber="1462315198">
+<target name="egit-4.6-staging" sequenceNumber="1463611910">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.2.13.v20150730"/>
@@ -44,8 +44,8 @@
<unit id="com.google.gson.source" version="2.2.4.v201311231704"/>
<unit id="com.jcraft.jsch" version="0.1.53.v201508180515"/>
<unit id="com.jcraft.jsch.source" version="0.1.53.v201508180515"/>
- <unit id="javaewah" version="0.7.9.v201401101600"/>
- <unit id="javaewah.source" version="0.7.9.v201401101600"/>
+ <unit id="javaewah" version="0.7.9.v201605172130"/>
+ <unit id="javaewah.source" version="0.7.9.v201605172130"/>
<unit id="javax.servlet" version="3.1.0.v201410161800"/>
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="org.apache.ant" version="1.9.6.v201510161327"/>
@@ -85,7 +85,7 @@
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
<unit id="org.tukaani.xz" version="1.3.0.v201308270617"/>
<unit id="org.tukaani.xz.source" version="1.3.0.v201308270617"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20160501200945/repository/"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20160518051658/repository/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
@@ -98,7 +98,7 @@
<unit id="org.eclipse.mylyn.context_feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.mylyn.sdk_feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/>
- <repository location="http://download.eclipse.org/releases/staging/"/>
+ <repository location="http://download.eclipse.org/staging/neon/"/>
</location>
</locations>
</target>
diff --git a/org.eclipse.egit.target/egit-4.6-staging.tpd b/org.eclipse.egit.target/egit-4.6-staging.tpd
index 4522cc97fb..77d29abea3 100644
--- a/org.eclipse.egit.target/egit-4.6-staging.tpd
+++ b/org.eclipse.egit.target/egit-4.6-staging.tpd
@@ -3,5 +3,5 @@ target "egit-4.6-staging" with source configurePhase
include "projects/jetty-9.2.13.tpd"
include "projects/swtbot-snapshot.tpd"
include "projects/mylyn-latest.tpd"
-include "orbit/S20160501200945-Neon.tpd"
+include "orbit/S20160518051658-Neon.tpd"
include "releasetrain/staging.tpd"
diff --git a/org.eclipse.egit.target/egit-4.6.target b/org.eclipse.egit.target/egit-4.6.target
index 12eefc7a54..88e2ff03de 100644
--- a/org.eclipse.egit.target/egit-4.6.target
+++ b/org.eclipse.egit.target/egit-4.6.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
-<target name="egit-4.6" sequenceNumber="1462292074">
+<target name="egit-4.6" sequenceNumber="1463611934">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.2.13.v20150730"/>
@@ -44,8 +44,8 @@
<unit id="com.google.gson.source" version="2.2.4.v201311231704"/>
<unit id="com.jcraft.jsch" version="0.1.53.v201508180515"/>
<unit id="com.jcraft.jsch.source" version="0.1.53.v201508180515"/>
- <unit id="javaewah" version="0.7.9.v201401101600"/>
- <unit id="javaewah.source" version="0.7.9.v201401101600"/>
+ <unit id="javaewah" version="0.7.9.v201605172130"/>
+ <unit id="javaewah.source" version="0.7.9.v201605172130"/>
<unit id="javax.servlet" version="3.1.0.v201410161800"/>
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="org.apache.ant" version="1.9.6.v201510161327"/>
@@ -85,7 +85,7 @@
<unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/>
<unit id="org.tukaani.xz" version="1.3.0.v201308270617"/>
<unit id="org.tukaani.xz.source" version="1.3.0.v201308270617"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20160501200945/repository/"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20160518051658/repository/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.6.tpd b/org.eclipse.egit.target/egit-4.6.tpd
index cbb326a7fe..a177501312 100644
--- a/org.eclipse.egit.target/egit-4.6.tpd
+++ b/org.eclipse.egit.target/egit-4.6.tpd
@@ -3,5 +3,5 @@ target "egit-4.6" with source configurePhase
include "projects/jetty-9.2.13.tpd"
include "projects/swtbot-snapshot.tpd"
include "projects/mylyn-latest.tpd"
-include "orbit/S20160501200945-Neon.tpd"
+include "orbit/S20160518051658-Neon.tpd"
include "releasetrain/4.6-neon.tpd"
diff --git a/org.eclipse.egit.target/orbit/S20160501200945-Neon.tpd b/org.eclipse.egit.target/orbit/S20160518051658-Neon.tpd
index 4e0f329a76..6e721caa27 100644
--- a/org.eclipse.egit.target/orbit/S20160501200945-Neon.tpd
+++ b/org.eclipse.egit.target/orbit/S20160518051658-Neon.tpd
@@ -1,13 +1,13 @@
-target "S20160501200945-Neon" with source configurePhase
+target "S20160518051658-Neon" with source configurePhase
// see http://download.eclipse.org/tools/orbit/downloads/
-location "http://download.eclipse.org/tools/orbit/downloads/drops/S20160501200945/repository/" {
+location "http://download.eclipse.org/tools/orbit/downloads/drops/S20160518051658/repository/" {
com.google.gson [2.2.4.v201311231704,2.2.4.v201311231704]
com.google.gson.source [2.2.4.v201311231704,2.2.4.v201311231704]
com.jcraft.jsch [0.1.53.v201508180515,0.1.53.v201508180515]
com.jcraft.jsch.source [0.1.53.v201508180515,0.1.53.v201508180515]
- javaewah [0.7.9.v201401101600,0.7.9.v201401101600]
- javaewah.source [0.7.9.v201401101600,0.7.9.v201401101600]
+ javaewah [0.7.9.v201605172130,0.7.9.v201605172130]
+ javaewah.source [0.7.9.v201605172130,0.7.9.v201605172130]
javax.servlet [3.1.0.v201410161800,3.1.0.v201410161800]
javax.servlet.source [3.1.0.v201410161800,3.1.0.v201410161800]
org.apache.ant [1.9.6.v201510161327,1.9.6.v201510161327]
diff --git a/org.eclipse.egit.target/releasetrain/staging.tpd b/org.eclipse.egit.target/releasetrain/staging.tpd
index 3a024b074f..70fdc1d219 100644
--- a/org.eclipse.egit.target/releasetrain/staging.tpd
+++ b/org.eclipse.egit.target/releasetrain/staging.tpd
@@ -1,6 +1,6 @@
target "staging" with source configurePhase
-location "http://download.eclipse.org/releases/staging/" {
+location "http://download.eclipse.org/staging/neon/" {
org.eclipse.sdk.ide lazy
org.eclipse.emf.sdk.feature.group lazy
org.eclipse.mylyn.commons.sdk.feature.group lazy
diff --git a/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java b/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/SmartImportWizardTest.java
index 6d69a0615c..c0d33f7f13 100644
--- a/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/EasymportWizardTest.java
+++ b/org.eclipse.egit.ui.importer.tests/src/org/eclipse/egit/ui/importer/tests/SmartImportWizardTest.java
@@ -46,11 +46,13 @@ import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+@Ignore
@RunWith(SWTBotJunit4ClassRunner.class)
-public class EasymportWizardTest {
+public class SmartImportWizardTest {
protected static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
diff --git a/org.eclipse.egit.ui.smartimport/META-INF/MANIFEST.MF b/org.eclipse.egit.ui.smartimport/META-INF/MANIFEST.MF
index ece119e819..573f525484 100644
--- a/org.eclipse.egit.ui.smartimport/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui.smartimport/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragment_name
Bundle-SymbolicName: org.eclipse.egit.ui.smartimport;singleton:=true
-Fragment-Host: org.eclipse.egit.ui
+Fragment-Host: org.eclipse.egit.ui;bundle-version="[4.4.0,4.5.0)"
Bundle-Version: 4.4.0.qualifier
Bundle-Vendor: %provider_name
Require-Bundle: org.eclipse.ui,
diff --git a/org.eclipse.egit.ui.smartimport/META-INF/p2.inf b/org.eclipse.egit.ui.smartimport/META-INF/p2.inf
new file mode 100644
index 0000000000..fb6936c185
--- /dev/null
+++ b/org.eclipse.egit.ui.smartimport/META-INF/p2.inf
@@ -0,0 +1,2 @@
+update.matchExp=providedCapabilities.exists(pc | pc.namespace == 'org.eclipse.equinox.p2.iu' && (pc.name == 'org.eclipse.egit.ui.smartimport' && pc.version < '$version$' || pc.name == 'org.eclipse.egit.ui.importer') )
+update.severity=0 \ No newline at end of file
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index ad75191040..bd77fb072f 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -248,6 +248,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
.getPreferences();
synchronized (prefs) {
prefs.put(RepositoryUtil.PREFS_DIRECTORIES, "");
+ prefs.put(RepositoryUtil.PREFS_DIRECTORIES_REL, "");
prefs.flush();
}
}
@@ -516,7 +517,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
protected static void createBranch(Repository myRepository,
String newRefName) throws IOException {
RefUpdate updateRef = myRepository.updateRef(newRefName);
- Ref sourceBranch = myRepository.getRef("refs/heads/master");
+ Ref sourceBranch = myRepository.exactRef("refs/heads/master");
ObjectId startAt = sourceBranch.getObjectId();
String startBranch = Repository.shortenRefName(sourceBranch.getName());
updateRef.setNewObjectId(startAt);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
index e048977827..abc5354e7a 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
@@ -96,7 +96,7 @@ public abstract class AbstractGitflowHandlerTest extends LocalRepositoryTestCase
}
protected Ref findBranch(String branchName) throws IOException {
- return repository.getRef(R_HEADS + branchName);
+ return repository.exactRef(R_HEADS + branchName);
}
protected void init() throws CoreException {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
index b6ed49ea0e..597febbaa5 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
@@ -10,6 +10,7 @@ package org.eclipse.egit.ui.gitflow;
import static org.eclipse.egit.gitflow.ui.internal.UIPreferences.FEATURE_FINISH_KEEP_BRANCH;
import static org.eclipse.egit.gitflow.ui.internal.UIPreferences.FEATURE_FINISH_SQUASH;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -91,6 +92,8 @@ public class FeatureFinishSquashHandlerTest extends
@Override
protected void preFinish() {
+ bot.waitUntil(shellIsActive(
+ UIText.FeatureFinishHandler_rewordSquashedCommitMessage));
String text = bot.styledText().getText();
text = text.substring(text.indexOf('\n'));
bot.styledText().setText(SQUASHED_COMMENT_SUMMARY + text);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java
index 6662edf33e..d7bfa87f4b 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/InitHandlerTest.java
@@ -104,7 +104,7 @@ public class InitHandlerTest extends AbstractGitflowHandlerTest {
assertEquals(HOTFIX_BRANCH_PREFIX, config.getHotfixPrefix());
assertEquals(VERSION_TAG_PREFIX, config.getVersionTagPrefix());
- assertNotNull(repository.getRef(Constants.R_HEADS + DEVELOP_BRANCH));
+ assertNotNull(repository.exactRef(Constants.R_HEADS + DEVELOP_BRANCH));
}
@Test
@@ -132,7 +132,8 @@ public class InitHandlerTest extends AbstractGitflowHandlerTest {
assertEquals(HOTFIX_BRANCH_PREFIX, config.getHotfixPrefix());
assertEquals(VERSION_TAG_PREFIX, config.getVersionTagPrefix());
- assertNotNull(localRepository.getRef(Constants.R_HEADS + DEVELOP_BRANCH));
+ assertNotNull(
+ localRepository.exactRef(Constants.R_HEADS + DEVELOP_BRANCH));
}
private void selectProject(String projectName) {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java
index 23a51e358d..eca7c943e0 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java
@@ -248,7 +248,7 @@ public class PushBranchWizardTest extends LocalRepositoryTestCase {
private void checkoutNewLocalBranch(String branchName)
throws Exception {
CreateLocalBranchOperation createBranch = new CreateLocalBranchOperation(
- repository, branchName, repository.getRef("master"),
+ repository, branchName, repository.findRef("master"),
UpstreamConfig.NONE);
createBranch.execute(null);
BranchOperation checkout = new BranchOperation(repository, branchName);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushToUpstreamTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushToUpstreamTest.java
index 0e19fa3ef6..b1f29cdd1d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushToUpstreamTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushToUpstreamTest.java
@@ -77,7 +77,7 @@ public class PushToUpstreamTest extends LocalRepositoryTestCase {
private void checkoutNewLocalBranch(String branchName)
throws Exception {
CreateLocalBranchOperation createBranch = new CreateLocalBranchOperation(
- repository, branchName, repository.getRef("master"),
+ repository, branchName, repository.findRef("master"),
UpstreamConfig.NONE);
createBranch.execute(null);
BranchOperation checkout = new BranchOperation(repository, branchName);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/submodule/SubmoduleUpdateTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/submodule/SubmoduleUpdateTest.java
index aa2d394e1f..94203c4da9 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/submodule/SubmoduleUpdateTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/submodule/SubmoduleUpdateTest.java
@@ -76,7 +76,7 @@ public class SubmoduleUpdateTest extends GitRepositoriesViewTestBase {
assertNotNull(subRepo);
subRepo.close();
- Ref head = subRepo.getRef(Constants.HEAD);
+ Ref head = subRepo.exactRef(Constants.HEAD);
assertNotNull(head);
assertTrue(head.isSymbolic());
assertEquals(Constants.R_HEADS + Constants.MASTER, head.getLeaf()
@@ -94,7 +94,7 @@ public class SubmoduleUpdateTest extends GitRepositoriesViewTestBase {
TestUtil.joinJobs(JobFamilies.SUBMODULE_UPDATE);
refreshAndWait();
- head = subRepo.getRef(Constants.HEAD);
+ head = subRepo.exactRef(Constants.HEAD);
assertNotNull(head);
assertFalse(head.isSymbolic());
assertEquals(repoHead, head.getObjectId());
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index 48ca9edd3f..16520a3a49 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -578,20 +578,27 @@ public class TestUtil {
* @return the {@code treeItem}
*/
public static SWTBotTreeItem expandAndWait(final SWTBotTreeItem treeItem) {
+ final String text = treeItem.getText();
treeItem.expand();
new SWTBot().waitUntil(new DefaultCondition() {
@Override
public boolean test() {
+ if (treeItem.widget.isDisposed()) {
+ return true; // Stop waiting and report failure below.
+ }
SWTBotTreeItem[] children = treeItem.getItems();
return children != null && children.length > 0;
}
@Override
public String getFailureMessage() {
- return "No children found for " + treeItem.getText();
+ return "No children found for " + text;
}
});
+ if (treeItem.widget.isDisposed()) {
+ fail("Widget disposed while waiting for expansion of node " + text);
+ }
return treeItem;
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
index ba34382aed..dc2fbb0c0c 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
@@ -401,7 +401,7 @@ public class HistoryViewTest extends LocalRepositoryTestCase {
@Ignore
public void testRebaseAlreadyUpToDate() throws Exception {
Repository repo = lookupRepository(repoFile);
- Ref stable = repo.getRef("stable");
+ Ref stable = repo.findRef("stable");
SWTBotTable table = getHistoryViewTable(PROJ1);
SWTBotTableItem stableItem = getTableItemWithId(table, stable.getObjectId());
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 739e989729..e8155b833b 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
@@ -115,7 +115,7 @@ public class StagingViewTest extends LocalRepositoryTestCase {
git.checkout().setName("master").call();
commitOneFileChange("on master");
- git.merge().include(repository.getRef("side")).call();
+ git.merge().include(repository.findRef("side")).call();
assertEquals(RepositoryState.MERGING, repository.getRepositoryState());
StagingViewTester stagingView = StagingViewTester
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionStagingViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionStagingViewTest.java
new file mode 100644
index 0000000000..dcab5bd543
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionStagingViewTest.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Thomas Wolf <thomas.wolf@paranor.ch>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.test.team.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
+import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
+import org.eclipse.egit.ui.internal.staging.StagingView;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Commit action
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class CommitActionStagingViewTest extends LocalRepositoryTestCase {
+ private File repositoryFile;
+
+ private boolean initialUseStagingView;
+
+ @Before
+ public void setup() throws Exception {
+ TestUtil.hideView(StagingView.VIEW_ID);
+ initialUseStagingView = Activator.getDefault().getPreferenceStore()
+ .getBoolean(UIPreferences.ALWAYS_USE_STAGING_VIEW);
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
+ Activator.getDefault().getPreferenceStore()
+ .setDefault(UIPreferences.STAGING_VIEW_SYNC_SELECTION, false);
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.STAGING_VIEW_SYNC_SELECTION, false);
+ repositoryFile = createProjectAndCommitToRepository();
+ Repository repo = lookupRepository(repositoryFile);
+ TestUtil.configureTestCommitterAsUser(repo);
+ // TODO delete the second project for the time being (.gitignore is
+ // currently not hiding the .project file from commit)
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ2);
+ File dotProject = new File(project.getLocation().toOSString(), ".project");
+ project.delete(false, false, null);
+ assertTrue(dotProject.delete());
+ }
+
+ @After
+ public void tearDown() {
+ Activator.getDefault().getPreferenceStore().setValue(
+ UIPreferences.ALWAYS_USE_STAGING_VIEW, initialUseStagingView);
+ Activator.getDefault().getPreferenceStore()
+ .setDefault(UIPreferences.STAGING_VIEW_SYNC_SELECTION, true);
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.STAGING_VIEW_SYNC_SELECTION, true);
+ }
+
+ @Test
+ public void testOpenStagingViewNoLinkWithSelection() throws Exception {
+ setTestFileContent("I have changed this");
+ SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ util.getProjectItems(projectExplorerTree, PROJ1)[0].select();
+ String menuString = util.getPluginLocalizedValue("CommitAction_label");
+ ContextMenuHelper.clickContextMenu(projectExplorerTree, "Team",
+ menuString);
+ TestUtil.waitUntilViewWithGivenIdShows(StagingView.VIEW_ID);
+ final Repository[] repo = { null };
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ StagingView view;
+ try {
+ view = (StagingView) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .showView(StagingView.VIEW_ID);
+ repo[0] = view.getCurrentRepository();
+ } catch (PartInitException e) {
+ // Ignore, repo[0] remains null
+ }
+ }
+ });
+ Repository repository = lookupRepository(repositoryFile);
+ assertNotNull("No repository found", repository);
+ assertEquals("Repository mismatch", repository, repo[0]);
+ }
+
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
index 91e13cae07..e64e85594d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
@@ -117,6 +117,7 @@ public class CommitNonWSChangesTest extends LocalRepositoryTestCase {
private void clickOnCommit() throws Exception {
SWTBotView repoView = TestUtil.showView(RepositoriesView.VIEW_ID);
+ TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);
SWTBotTree tree = repoView.bot().tree();
TestUtil.waitUntilTreeHasNodeContainsText(bot, tree, REPO1, 10000);
tree.getAllItems()[0].contextMenu("Commit...").click();
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
index 7407820880..b217f72392 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
@@ -449,6 +449,7 @@ public class GitRepositoriesViewBranchHandlingTest extends
if (!changed.get())
fail("We should have received a config change event");
+ refreshAndWait(); // Repo view updates itself after config change.
rebase = repo.getConfig().getBoolean(
ConfigConstants.CONFIG_BRANCH_SECTION, "configTest",
ConfigConstants.CONFIG_KEY_REBASE, false);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java
index 35c103d100..7f44b2afea 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java
@@ -152,7 +152,7 @@ public class GitRepositoriesViewFetchAndPushTest extends
confirmed.close();
assertTrue("Up to date expected", uptodate);
// touch and run again: expect new branch
- String objectIdBefore = repository.getRef(repository.getFullBranch())
+ String objectIdBefore = repository.exactRef(repository.getFullBranch())
.getLeaf().getObjectId().name();
objectIdBefore = objectIdBefore.substring(0, 7);
touchAndSubmit(null);
@@ -236,7 +236,7 @@ public class GitRepositoriesViewFetchAndPushTest extends
deleteAllProjects();
shareProjects(clonedRepositoryFile2);
- String objid = repository.getRef("refs/heads/master").getTarget()
+ String objid = repository.exactRef("refs/heads/master").getTarget()
.getObjectId().name();
objid = objid.substring(0, 7);
touchAndSubmit(null);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index 6e2cba3d54..c1d38387ab 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -263,6 +263,7 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
assertEquals(myRepoViewUtil.getWorkdirItem(tree, repositoryFile)
.getText(), wizardNode);
shell.close();
+ tree = getOrOpenView().bot().tree();
// start wizard from .git
TestUtil.expandAndWait(
myRepoViewUtil.getWorkdirItem(tree, repositoryFile))
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java
index 88766f80a9..42bf48a756 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java
@@ -75,7 +75,7 @@ public abstract class GitRepositoriesViewTestBase extends
// that we push two branches to remote
String newRefName = "refs/heads/stable";
RefUpdate updateRef = myRepository.updateRef(newRefName);
- Ref sourceBranch = myRepository.getRef("refs/heads/master");
+ Ref sourceBranch = myRepository.exactRef("refs/heads/master");
ObjectId startAt = sourceBranch.getObjectId();
String startBranch = Repository.shortenRefName(sourceBranch.getName());
updateRef.setNewObjectId(startAt);
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
index 5311813a30..41c14f5f8c 100644
--- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
@@ -91,7 +91,7 @@ Export-Package: org.eclipse.egit.ui;version="4.4.0";x-friends:="org.eclipse.egit
org.eclipse.egit.ui.internal.history.command;version="4.4.0";x-internal:=true,
org.eclipse.egit.ui.internal.importing;version="4.4.0";x-internal:=true,
org.eclipse.egit.ui.internal.merge;version="4.4.0";x-internal:=true,
- org.eclipse.egit.ui.internal.operations;version="4.4.0";x-internal:=true,
+ org.eclipse.egit.ui.internal.operations;version="4.4.0";x-friends:="org.eclipse.egit.gitflow.ui",
org.eclipse.egit.ui.internal.patch;version="4.4.0";x-internal:=true,
org.eclipse.egit.ui.internal.preferences;version="4.4.0";x-internal:=true,
org.eclipse.egit.ui.internal.provisional.wizards;version="4.4.0";x-internal:=true,
diff --git a/org.eclipse.egit.ui/build.properties b/org.eclipse.egit.ui/build.properties
index 6e9055d118..8553487735 100644
--- a/org.eclipse.egit.ui/build.properties
+++ b/org.eclipse.egit.ui/build.properties
@@ -7,6 +7,7 @@ bin.includes = META-INF/,\
icons/,\
plugin.properties,\
.options,\
- css/
+ css/,\
+ schema/
src.includes = about.html,\
icons/
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index 0eb5319c95..313263936b 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -179,9 +179,11 @@ HistoryViewCommandsLabel = History View Commands
HistoryViewCommands.extension.name = The history view commands
CommitViewerCommands.extension.name = The commit viewer commands
CompareCommand.name = Compare with each other
+CompareWithMenu.label= Comp&are With
CompareWithWorkTreeCommand.name = Compare with Working Tree
CompareWithCommitCommand.name = Compare with Commit...
CompareWithHistoryCommand.name = Compare with Branch, Tag or Reference...
+ReplaceWithMenu.label=Rep&lace With
ReplaceWithPreviousCommand.name = Replace with Previous Revision
OpenCommand.name = Open
CompareModeCommandParameter.name = Compare mode
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index dd0345182d..39bce40930 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -3586,6 +3586,24 @@
</and>
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.egit.ui.RepositoriesViewOpen"
+ label="%OpenInCommitViewerCommand.name"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <instanceof
+ value="org.eclipse.egit.ui.internal.repository.tree.StashedCommitNode">
+ </instanceof>
+ </iterate>
+ </and>
+ </visibleWhen>
+ </command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.egit.ui.RepositoriesView?after=repo-4">
@@ -4735,7 +4753,7 @@
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu
id="compareWithMenu"
- label="Compare With">
+ label="%CompareWithMenu.label">
<separator
name="compareWithGroup">
</separator>
@@ -4754,7 +4772,7 @@
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu
id="replaceWithMenu"
- label="Replace With">
+ label="%ReplaceWithMenu.label">
<separator
name="replaceWithGroup">
</separator>
@@ -5283,6 +5301,10 @@
icon="icons/obj16/open-commit.gif">
</image>
<image
+ commandId="org.eclipse.egit.ui.RepositoriesViewOpen"
+ icon="icons/obj16/open-commit.gif">
+ </image>
+ <image
commandId="org.eclipse.egit.ui.history.Revert"
icon="icons/obj16/revert.gif">
</image>
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
index bda01b84b0..9f24738e7c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
@@ -934,7 +934,7 @@ public class CompareUtils {
*/
public static ITypedElement getHeadTypedElement(Repository repository, String repoRelativePath) {
try {
- Ref head = repository.getRef(Constants.HEAD);
+ Ref head = repository.exactRef(Constants.HEAD);
if (head == null || head.getObjectId() == null)
// Initial import, not yet a HEAD commit
return new EmptyTypedElement(""); //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIRepositoryUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIRepositoryUtils.java
index c90f937fbf..0ffa34ac4b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIRepositoryUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIRepositoryUtils.java
@@ -46,8 +46,11 @@ public final class UIRepositoryUtils {
*/
public static boolean handleUncommittedFiles(Repository repo, Shell shell)
throws GitAPIException {
- Status status = new Git(repo).status().call();
- if (status.hasUncommittedChanges()) {
+ Status status = null;
+ try (Git git = new Git(repo)) {
+ status = git.status().call();
+ }
+ if (status != null && status.hasUncommittedChanges()) {
List<String> files = new ArrayList<>(status.getModified());
Collections.sort(files);
String repoName = Activator.getDefault().getRepositoryUtil()
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index cadf297e01..2b9c129452 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -16,7 +16,7 @@
* Copyright (C) 2015, Jan-Ove Weichel <ovi.weichel@gmail.com>
* Copyright (C) 2015, Laurent Delaigue <laurent.delaigue@obeo.fr>
* Copyright (C) 2015, Denis Zygann <d.zygann@web.de>
- * Copyright (C) 2016, Lars Vogel <Lars.Vogel@vogella.com
+ * Copyright (C) 2016, Lars Vogel <Lars.Vogel@vogella.com>
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2736,6 +2736,27 @@ public class UIText extends NLS {
public static String PushToGerritPage_Title;
/** */
+ public static String PushToGerritPage_TopicCollidesWithBranch;
+
+ /** */
+ public static String PushToGerritPage_TopicContentProposalHoverText;
+
+ /** */
+ public static String PushToGerritPage_TopicHasWhitespace;
+
+ /** */
+ public static String PushToGerritPage_TopicInvalidCharacters;
+
+ /** */
+ public static String PushToGerritPage_TopicLabel;
+
+ /** */
+ public static String PushToGerritPage_TopicSaveFailure;
+
+ /** */
+ public static String PushToGerritPage_TopicUseLabel;
+
+ /** */
public static String PushToGerritPage_UriLabel;
/** */
@@ -3138,12 +3159,6 @@ public class UIText extends NLS {
public static String BranchSelectionAndEditDialog_ErrorCouldNotRenameRef;
/** */
- public static String BranchSelectionAndEditDialog_QuestionNewBranchTitle;
-
- /** */
- public static String BranchSelectionAndEditDialog_QuestionNewBranchNameMessage;
-
- /** */
public static String BranchSelectionAndEditDialog_NewBranch;
/** */
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 729e805188..92a9ff2a15 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
@@ -8,6 +8,7 @@
* Copyright (C) 2011, Jens Baumgart <jens.baumgart@sap.com>
* Copyright (C) 2011, Benjamin Muskalla <benjamin.muskalla@tasktop.com>
* Copyright (C) 2012, Fran├žois Rey <eclipse.org_@_francois_._rey_._name>
+ * Copyright (C) 2016, Thomas Wolf <thomas.wolf@paranor.ch>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -53,6 +54,9 @@ public class CommitActionHandler extends RepositoryActionHandler {
StagingView view = (StagingView) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.showView(StagingView.VIEW_ID);
+ if (view.getCurrentRepository() != repository) {
+ view.reload(repository);
+ }
view.setFocus();
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java
index 7598cf2a67..96940b62c7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java
@@ -143,7 +143,7 @@ public class MergeActionHandler extends RepositoryActionHandler {
public static boolean checkMergeIsPossible(Repository repository, Shell shell) {
String message = null;
try {
- Ref head = repository.getRef(Constants.HEAD);
+ Ref head = repository.exactRef(Constants.HEAD);
if (head == null || !head.isSymbolic())
message = UIText.MergeAction_HeadIsNoBranch;
else if (!repository.getRepositoryState().equals(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java
index 12c5a48e22..164e2f8b2b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java
@@ -50,7 +50,7 @@ public class PullFromUpstreamActionHandler extends RepositoryActionHandler {
|| !fullBranch.startsWith(Constants.R_REFS)) {
return false;
}
- Ref head = repo.getRef(Constants.HEAD);
+ Ref head = repo.exactRef(Constants.HEAD);
if (head == null || head.getObjectId() == null) {
return false;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushActionHandler.java
index e176f25030..5fb3b4ac36 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushActionHandler.java
@@ -60,7 +60,7 @@ public class PushActionHandler extends RepositoryActionHandler {
if (repository == null) {
return false;
}
- Ref ref = repository.getRef(Constants.HEAD);
+ Ref ref = repository.exactRef(Constants.HEAD);
return ref != null && ref.getObjectId() != null;
} catch (IOException e) {
Activator.handleError(e.getMessage(), e, false);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java
index 5b1e67a75b..04f380f45c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java
@@ -78,7 +78,7 @@ public class PushUpstreamOrBranchActionHandler extends RepositoryActionHandler {
private static Ref getHeadIfSymbolic(Repository repository) {
try {
- Ref head = repository.getRef(Constants.HEAD);
+ Ref head = repository.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic())
return head;
else
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
index 60ef68d053..046610a018 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
@@ -479,7 +479,7 @@ abstract class RepositoryActionHandler extends AbstractHandler {
rw.setTreeFilter(filter);
}
- Ref head = repository.getRef(Constants.HEAD);
+ Ref head = repository.exactRef(Constants.HEAD);
if (head == null) {
return result;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java
index 56f12efd5e..b3c1f95382 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java
@@ -101,7 +101,7 @@ public class SwitchToMenu extends ContributionItem implements
ConfigConstants.CONFIG_WORKFLOW_SECTION, null,
ConfigConstants.CONFIG_KEY_DEFBRANCHSTARTPOINT);
try {
- Ref ref = repository.getRef(sourceRef);
+ Ref ref = repository.findRef(sourceRef);
if (ref != null)
BranchOperationUI.createWithRef(repository,
ref.getName()).start();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWorkspaceActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWorkspaceActionHandler.java
index 54d6edb7a9..73a2f1ae89 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWorkspaceActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWorkspaceActionHandler.java
@@ -124,7 +124,7 @@ public class SynchronizeWorkspaceActionHandler extends RepositoryActionHandler {
Ref ref;
try {
- ref = repo.getRef(HEAD);
+ ref = repo.exactRef(HEAD);
} catch (IOException e) {
ref = null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java
index bdd6259ef6..283aa6f34d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitSelectRepositoryPage.java
@@ -217,7 +217,7 @@ public class GitSelectRepositoryPage extends WizardPage {
private void refreshRepositoryList() {
List<String> dirsBefore = (List<String>) tv.getInput();
List<String> dirsAfter = util.getConfiguredRepositories();
- if (!dirsBefore.containsAll(dirsAfter)) {
+ if (dirsBefore != null && !dirsBefore.containsAll(dirsAfter)) {
tv.setInput(dirsAfter);
for (String dir : dirsAfter)
if (!dirsBefore.contains(dir))
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java
index 2ce74e4528..f33dd63ff3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java
@@ -99,6 +99,9 @@ public abstract class AbstractRebaseCommandHandler extends AbstractSharedCommand
public void done(IJobChangeEvent cevent) {
finishRebaseInteractive();
IStatus result = cevent.getJob().getResult();
+ if (result == null) {
+ return;
+ }
// if a rebase was started, returned with an exception
// and left the repository in an unsafe state, try to
// abort and show exception
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java
index cfc401ae2c..b8248458e5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java
@@ -91,7 +91,7 @@ public class RebaseCurrentRefCommand extends AbstractRebaseCommandHandler {
if (rebaseTargetSelectionDialog.open() == IDialogConstants.OK_ID) {
String refName = rebaseTargetSelectionDialog.getRefName();
try {
- ref = repository.getRef(refName);
+ ref = repository.findRef(refName);
} catch (IOException e) {
throw new ExecutionException(e.getMessage(), e);
}
@@ -135,7 +135,7 @@ public class RebaseCurrentRefCommand extends AbstractRebaseCommandHandler {
private static boolean hasHead(Repository repo) {
try {
- Ref headRef = repo.getRef(Constants.HEAD);
+ Ref headRef = repo.exactRef(Constants.HEAD);
return headRef != null && headRef.getObjectId() != null;
} catch (IOException e) {
return false;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
index 835f1b91e7..64952bdbc3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012-2014 Red Hat, Inc. Distributed under license by Red Hat, Inc.
+ * Copyright (c) 2012-2016 Red Hat, Inc, and others. Distributed under license by Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -163,51 +163,58 @@ public class CommitJob extends Job {
}
private void pushUpstream(final RevCommit commit, final PushMode pushTo) {
- RemoteConfig config = SimpleConfigurePushDialog
+ final RemoteConfig config = SimpleConfigurePushDialog
.getConfiguredRemote(repository);
- if (pushTo == PushMode.GERRIT) {
- final Wizard pushWizard = new PushToGerritWizard(repository);
- openPushWizard(pushWizard);
- } else if (config == null) {
+ if (pushTo == PushMode.GERRIT || config == null) {
+ final Display display = PlatformUI.getWorkbench().getDisplay();
+ display.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ Wizard pushWizard = getPushWizard(commit, pushTo);
+ if (pushWizard != null) {
+ WizardDialog wizardDialog = new WizardDialog(
+ display.getActiveShell(), pushWizard);
+ wizardDialog.setHelpAvailable(true);
+ wizardDialog.open();
+ }
+ }
+ });
+ } else {
+ PushOperationUI op = new PushOperationUI(repository,
+ config.getName(), false);
+ op.start();
+ }
+ }
+
+ private Wizard getPushWizard(final RevCommit commit,
+ final PushMode pushTo) {
+ switch (pushTo) {
+ case GERRIT:
+ return new PushToGerritWizard(repository);
+ case UPSTREAM:
try {
- Wizard pushWizard = null;
String fullBranch = repository.getFullBranch();
if (fullBranch != null
&& fullBranch.startsWith(Constants.R_HEADS)) {
- Ref ref = repository.getRef(fullBranch);
- pushWizard = new PushBranchWizard(repository, ref);
+ Ref ref = repository.exactRef(fullBranch);
+ return new PushBranchWizard(repository, ref);
} else {
- pushWizard = new PushBranchWizard(repository,
+ return new PushBranchWizard(repository,
commit.getId());
}
- openPushWizard(pushWizard);
} catch (IOException e) {
Activator.handleError(
NLS.bind(UIText.CommitUI_pushFailedMessage, e), e,
true);
+ return null;
}
- } else {
- PushOperationUI op = new PushOperationUI(repository,
- config.getName(), false);
- op.start();
+ default:
+ return null;
}
}
- private void openPushWizard(final Wizard pushWizard) {
- final Display display = Display.getDefault();
- display.asyncExec(new Runnable() {
-
- @Override
- public void run() {
- WizardDialog wizardDialog = new WizardDialog(display
- .getActiveShell(), pushWizard);
- wizardDialog.setHelpAvailable(true);
- wizardDialog.open();
- }
- });
- }
-
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.COMMIT.equals(family))
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
index e01206f4b3..af2f9f0872 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
@@ -377,7 +377,7 @@ public class RefSpecPanel {
Ref HEAD = null;
try {
- HEAD = localDb.getRef(Constants.HEAD);
+ HEAD = localDb.exactRef(Constants.HEAD);
} catch (IOException e) {
Activator.logError("Couldn't read HEAD from local repository", e); //$NON-NLS-1$
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java
index 15eb633b76..e0da642575 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java
@@ -733,7 +733,13 @@ public class RepositorySelectionPage extends WizardPage implements IRepositorySe
eventDepth++;
if (eventDepth == 1) {
uri = u;
- uriText.setText(uri.toString());
+ String oldUriText = uriText.getText();
+ String newUriText = uri.toString();
+ // avoid moving the cursor to the first position if there are no
+ // changes by this automatic update
+ if (!oldUriText.equals(newUriText)) {
+ uriText.setText(newUriText);
+ }
checkPage();
}
} finally {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java
index 46a1ffa5a8..f10b1ec214 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java
@@ -142,7 +142,7 @@ class GitDocument extends Document implements RefsChangedListener {
return;
}
} else {
- if (repository.getRef(Constants.HEAD) == null) {
+ if (repository.exactRef(Constants.HEAD) == null) {
// Complain only if not an unborn branch
String msg = NLS.bind(UIText.GitDocument_errorResolveQuickdiff,
new Object[] { baseline, resource, repository });
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/AbstractBranchSelectionDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/AbstractBranchSelectionDialog.java
index 963b9df84d..650c5a333b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/AbstractBranchSelectionDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/AbstractBranchSelectionDialog.java
@@ -368,9 +368,9 @@ public abstract class AbstractBranchSelectionDialog extends TitleAreaDialog {
/**
* Enables the OK button. No-op in case Dialog#createButtonsForButtonBar has
* been overridden and the button has not been created.
- *
+ *
* @param enabled
- *
+ *
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(Composite)
*/
protected void setOkButtonEnabled(boolean enabled) {
@@ -381,7 +381,7 @@ public abstract class AbstractBranchSelectionDialog extends TitleAreaDialog {
/**
* Returns <code>true</code> if the OK button has been created and is
* enabled.
- *
+ *
* @return the OK button's enabled state or <code>false</code> if the button
* has not been created.
*/
@@ -405,17 +405,17 @@ public abstract class AbstractBranchSelectionDialog extends TitleAreaDialog {
RepositoryTreeNode node;
try {
if (refName.startsWith(Constants.R_HEADS)) {
- Ref ref = repo.getRef(refName);
+ Ref ref = repo.exactRef(refName);
if (ref == null)
return false;
node = new RefNode(localBranches, repo, ref);
} else if (refName.startsWith(Constants.R_REMOTES)) {
- Ref ref = repo.getRef(refName);
+ Ref ref = repo.exactRef(refName);
if (ref == null)
return false;
node = new RefNode(remoteBranches, repo, ref);
} else if (Constants.HEAD.equals(refName)) {
- Ref ref = repo.getRef(refName);
+ Ref ref = repo.exactRef(refName);
if (ref == null)
return false;
node = new AdditionalRefNode(references, repo, ref);
@@ -424,13 +424,13 @@ public abstract class AbstractBranchSelectionDialog extends TitleAreaDialog {
.mapCommitToRef(repo, refName, false);
if (mappedRef != null
&& mappedRef.startsWith(Constants.R_REMOTES)) {
- Ref ref = repo.getRef(mappedRef);
+ Ref ref = repo.exactRef(mappedRef);
if (ref == null)
return false;
node = new RefNode(remoteBranches, repo, ref);
} else if (mappedRef != null
&& mappedRef.startsWith(Constants.R_TAGS)) {
- Ref ref = repo.getRef(mappedRef);
+ Ref ref = repo.exactRef(mappedRef);
if (ref == null)
return false;
node = new TagNode(tags, repo, ref);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchRenameDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchRenameDialog.java
index 18c69cb909..497e5b62cf 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchRenameDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchRenameDialog.java
@@ -40,6 +40,8 @@ public class BranchRenameDialog extends TitleAreaDialog {
private Text name;
+ private String newName;
+
/**
* @param parentShell
* @param repository
@@ -118,7 +120,7 @@ public class BranchRenameDialog extends TitleAreaDialog {
protected void buttonPressed(int buttonId) {
if (buttonId == OK)
try {
- String newName = name.getText();
+ newName = name.getText();
new RenameBranchOperation(repository, branchToRename, newName)
.execute(null);
} catch (CoreException e) {
@@ -129,4 +131,13 @@ public class BranchRenameDialog extends TitleAreaDialog {
}
super.buttonPressed(buttonId);
}
+
+ /**
+ * @return the name of the branch after the rename operation. This is only
+ * valid after the dialog has been opened and finished with the OK
+ * button.
+ */
+ public String getNewName() {
+ return newName;
+ }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionAndEditDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionAndEditDialog.java
index f875378375..43ced3af2e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionAndEditDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionAndEditDialog.java
@@ -19,17 +19,14 @@ import java.util.Iterator;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.ValidationUtils;
import org.eclipse.egit.ui.internal.branch.BranchOperationUI;
import org.eclipse.egit.ui.internal.repository.CreateBranchWizard;
import org.eclipse.egit.ui.internal.repository.tree.RefNode;
-import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
@@ -178,7 +175,7 @@ public class BranchSelectionAndEditDialog extends
ConfigConstants.CONFIG_WORKFLOW_SECTION, null,
ConfigConstants.CONFIG_KEY_DEFBRANCHSTARTPOINT);
try {
- Ref ref = repo.getRef(sourceRef);
+ Ref ref = repo.findRef(sourceRef);
if (ref != null) {
base = ref.getName();
}
@@ -223,40 +220,17 @@ public class BranchSelectionAndEditDialog extends
renameButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ Ref selectedRef = refFromDialog();
- String refName = refNameFromDialog();
- String refPrefix;
+ String namePrefix = selectedRef.getName()
+ .startsWith(Constants.R_REMOTES) ? Constants.R_REMOTES
+ : Constants.R_HEADS;
- if (refName.startsWith(Constants.R_HEADS))
- refPrefix = Constants.R_HEADS;
- else if (refName.startsWith(Constants.R_REMOTES))
- refPrefix = Constants.R_REMOTES;
- else if (refName.startsWith(Constants.R_TAGS))
- refPrefix = Constants.R_TAGS;
- else {
- // the button should be disabled anyway, but we check again
- return;
- }
-
- String branchName = refName.substring(refPrefix.length());
-
- InputDialog labelDialog = getRefNameInputDialog(
- NLS.bind(
- UIText.BranchSelectionAndEditDialog_QuestionNewBranchNameMessage,
- branchName, refPrefix), refPrefix, branchName);
- if (labelDialog.open() == Window.OK) {
- String newRefName = refPrefix + labelDialog.getValue();
- try {
- new Git(repo).branchRename().setOldName(refName)
- .setNewName(labelDialog.getValue()).call();
- branchTree.refresh();
- markRef(newRefName);
- } catch (Throwable e1) {
- reportError(
- e1,
- UIText.BranchSelectionAndEditDialog_ErrorCouldNotRenameRef,
- refName, newRefName, e1.getMessage());
- }
+ BranchRenameDialog dialog = new BranchRenameDialog(getShell(),
+ repo, selectedRef);
+ if (dialog.open() == Window.OK) {
+ branchTree.refresh();
+ markRef(namePrefix + dialog.getNewName());
}
}
});
@@ -297,17 +271,6 @@ public class BranchSelectionAndEditDialog extends
return deleteButton;
}
- private InputDialog getRefNameInputDialog(String prompt,
- final String refPrefix, String initialValue) {
- InputDialog labelDialog = new InputDialog(getShell(),
- UIText.BranchSelectionAndEditDialog_QuestionNewBranchTitle,
- prompt,
- initialValue, ValidationUtils.getRefNameInputValidator(repo,
- refPrefix, true));
- labelDialog.setBlockOnOpen(true);
- return labelDialog;
- }
-
private void reportError(Throwable e, String message, Object... args) {
String msg = NLS.bind(message, args);
Activator.handleError(msg, e, true);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
index e271dcfa29..cbc674cdf1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
@@ -1157,11 +1157,10 @@ public class CommitDialog extends TitleAreaDialog {
boolean ignoreErrorsValue = ignoreErrors == null ? true
: !ignoreErrors.getSelection();
- @SuppressWarnings("boxing")
boolean hasErrorsOrWarnings = getPreferenceStore()
.getBoolean(UIPreferences.WARN_BEFORE_COMMITTING)
? (getProblemsSeverity() >= Integer
- .valueOf(getPreferenceStore().getString(
+ .parseInt(getPreferenceStore().getString(
UIPreferences.WARN_BEFORE_COMMITTING_LEVEL))
&& ignoreErrorsValue)
: false;
@@ -1183,12 +1182,11 @@ public class CommitDialog extends TitleAreaDialog {
}
}
setMessage(message, type);
- @SuppressWarnings("boxing")
boolean commitBlocked = getPreferenceStore()
.getBoolean(UIPreferences.WARN_BEFORE_COMMITTING)
&& getPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT)
? (getProblemsSeverity() >= Integer
- .valueOf(getPreferenceStore().getString(
+ .parseInt(getPreferenceStore().getString(
UIPreferences.BLOCK_COMMIT_LEVEL))
&& ignoreErrorsValue)
: false;
@@ -1268,15 +1266,18 @@ public class CommitDialog extends TitleAreaDialog {
return new Action(UIText.CommitDialog_AddFileOnDiskToIndex) {
@Override
public void run() {
- AddCommand addCommand = new Git(repository).add();
- for (Iterator<?> it = selection.iterator(); it.hasNext();) {
- CommitItem commitItem = (CommitItem) it.next();
- addCommand.addFilepattern(commitItem.path);
- }
- try {
- addCommand.call();
- } catch (Exception e) {
- Activator.logError(UIText.CommitDialog_ErrorAddingFiles, e);
+ try (Git git = new Git(repository)) {
+ AddCommand addCommand = git.add();
+ for (Iterator<?> it = selection.iterator(); it.hasNext();) {
+ CommitItem commitItem = (CommitItem) it.next();
+ addCommand.addFilepattern(commitItem.path);
+ }
+ try {
+ addCommand.call();
+ } catch (Exception e) {
+ Activator.logError(UIText.CommitDialog_ErrorAddingFiles,
+ e);
+ }
}
for (Iterator<?> it = selection.iterator(); it.hasNext();) {
CommitItem commitItem = (CommitItem) it.next();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/RenameBranchDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/RenameBranchDialog.java
index 90ae66df58..1e1e2166ba 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/RenameBranchDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/RenameBranchDialog.java
@@ -75,9 +75,9 @@ public class RenameBranchDialog extends AbstractBranchSelectionDialog {
refPrefix), refPrefix, branchName);
if (labelDialog.open() == Window.OK) {
String newRefName = refPrefix + labelDialog.getValue();
- try {
- new Git(repo).branchRename().setOldName(refName).setNewName(
- labelDialog.getValue()).call();
+ try (Git git = new Git(repo)) {
+ git.branchRename().setOldName(refName)
+ .setNewName(labelDialog.getValue()).call();
branchTree.refresh();
markRef(newRefName);
} catch (Throwable e1) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
index 8a17fe6120..1d194607a8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
@@ -64,7 +64,6 @@ import org.eclipse.ui.part.IShowInSource;
*/
public class GitAdapterFactory implements IAdapterFactory {
- private Object historyPageSource = new GitHistoryPageSource();
private GitModelWorkbenchAdapter gitModelWorkbenchAdapter;
private static final IWorkspaceRoot root = ResourcesPlugin.getWorkspace()
@@ -73,7 +72,7 @@ public class GitAdapterFactory implements IAdapterFactory {
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType.isAssignableFrom(IHistoryPageSource.class)) {
- return historyPageSource;
+ return GitHistoryPageSource.INSTANCE;
}
if (IWorkbenchAdapter.class == adapterType) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java
index d868b8832d..040c5e6979 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java
@@ -810,8 +810,9 @@ public class FetchGerritChangePage extends WizardPage {
bop.execute(monitor);
if (doCheckout) {
- CheckoutCommand co = new Git(repository).checkout();
- try {
+ CheckoutCommand co = null;
+ try (Git git = new Git(repository)) {
+ co = git.checkout();
co.setName(textForBranch).call();
} catch (CheckoutConflictException e) {
final CheckoutResult result = co.getResult();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/SimpleConfigureFetchDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/SimpleConfigureFetchDialog.java
index 7b9f5511ac..eb24469250 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/SimpleConfigureFetchDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/SimpleConfigureFetchDialog.java
@@ -596,7 +596,7 @@ public class SimpleConfigureFetchDialog extends TitleAreaDialog {
Ref source;
try {
// TODO better checks for wild-cards and such
- source = repository.getRef(spec.getDestination());
+ source = repository.findRef(spec.getDestination());
} catch (IOException e1) {
source = null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPageSource.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPageSource.java
index 0ea3a768a1..9fe54ff16a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPageSource.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPageSource.java
@@ -17,6 +17,16 @@ import org.eclipse.ui.part.Page;
* A helper class for constructing the {@link GitHistoryPage}.
*/
public class GitHistoryPageSource extends HistoryPageSource {
+
+ /**
+ * The instance to use if needed.
+ */
+ public static final GitHistoryPageSource INSTANCE = new GitHistoryPageSource();
+
+ private GitHistoryPageSource() {
+ super();
+ }
+
@Override
public boolean canShowHistoryFor(final Object object) {
return GitHistoryPage.canShowHistoryFor(object);
@@ -27,4 +37,14 @@ public class GitHistoryPageSource extends HistoryPageSource {
// don't set the input, the framework does this for us
return new GitHistoryPage();
}
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof GitHistoryPageSource;
+ }
+
+ @Override
+ public int hashCode() {
+ return 42;
+ }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java
index 2120866158..b62aefadb8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/HistoryPageInput.java
@@ -146,7 +146,7 @@ public class HistoryPageInput {
*/
public Ref getHead() {
try {
- Ref h = repo.getRef(Constants.HEAD);
+ Ref h = repo.exactRef(Constants.HEAD);
if (h != null && h.isSymbolic())
return h;
return null;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java
index 2e8a47abb3..8e6ac5c10a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java
@@ -126,7 +126,8 @@ public class PushBranchWizard extends Wizard {
@Override
public boolean canFinish() {
- return getContainer().getCurrentPage() == confirmationPage;
+ return getContainer().getCurrentPage() == confirmationPage
+ && confirmationPage.isPageComplete();
}
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
index 6934250a65..fdb57bb061 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2015 SAP SE and others.
+ * Copyright (c) 2012, 2016 SAP SE and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
* Christian Georgi (SAP SE) - Bug 466900 (Make PushResultDialog amodal)
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 449493: Topic input
*******************************************************************************/
package org.eclipse.egit.ui.internal.push;
@@ -16,7 +17,9 @@ import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -30,6 +33,7 @@ import org.eclipse.egit.core.op.PushOperationResult;
import org.eclipse.egit.core.op.PushOperationSpecification;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIUtils;
+import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.jface.bindings.keys.KeyStroke;
@@ -38,14 +42,18 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.BranchConfig;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.URIish;
@@ -53,9 +61,12 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -72,6 +83,15 @@ class PushToGerritPage extends WizardPage {
private static final String LAST_BRANCH_POSTFIX = ".lastBranch"; //$NON-NLS-1$
+ private static final String LAST_TOPICS_POSTFIX = ".lastTopics"; //$NON-NLS-1$
+
+ private static final String GERRIT_TOPIC_KEY = "gerritTopic"; //$NON-NLS-1$
+
+ private static final String GERRIT_TOPIC_USE_KEY = "gerritTopicUse"; //$NON-NLS-1$
+
+ private static final Pattern WHITESPACE = Pattern
+ .compile("\\p{javaWhitespace}"); //$NON-NLS-1$
+
private final Repository repository;
private final IDialogSettings settings;
@@ -88,6 +108,27 @@ class PushToGerritPage extends WizardPage {
private Text branchText;
+ private Button useTopic;
+
+ private Label topicLabel;
+
+ private Text topicText;
+
+ private Set<String> knownRemoteRefs = new TreeSet<>(
+ String.CASE_INSENSITIVE_ORDER);
+
+ @SuppressWarnings("serial")
+ private Map<String, String> topicProposals = new LinkedHashMap<String, String>(
+ 30, 0.75f, true) {
+
+ private static final int TOPIC_PROPOSALS_MAXIMUM = 20;
+
+ @Override
+ protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
+ return size() > TOPIC_PROPOSALS_MAXIMUM;
+ }
+ };
+
/**
* @param repository
*/
@@ -113,6 +154,7 @@ class PushToGerritPage extends WizardPage {
@Override
public void createControl(Composite parent) {
+ loadKnownRemoteRefs();
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(3, false));
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
@@ -132,7 +174,7 @@ class PushToGerritPage extends WizardPage {
// we visualize the prefix here
prefixCombo = new Combo(main, SWT.READ_ONLY | SWT.DROP_DOWN);
prefixCombo.add(GerritUtil.REFS_FOR);
- prefixCombo.add("refs/drafts/"); //$NON-NLS-1$
+ prefixCombo.add(GerritUtil.REFS_DRAFTS);
prefixCombo.select(0);
branchTextlabel.setText(UIText.PushToGerritPage_BranchLabel);
@@ -145,7 +187,7 @@ class PushToGerritPage extends WizardPage {
}
});
- // give focus to the nameText if label is activated using the mnemonic
+ // give focus to the branchText if label is activated using the mnemonic
branchTextlabel.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
@@ -155,6 +197,40 @@ class PushToGerritPage extends WizardPage {
});
addRefContentProposalToText(branchText);
+ useTopic = new Button(main, SWT.CHECK | SWT.LEFT);
+ useTopic.setText(UIText.PushToGerritPage_TopicUseLabel);
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
+ .applyTo(useTopic);
+ topicLabel = new Label(main, SWT.NONE);
+ topicLabel.setText(UIText.PushToGerritPage_TopicLabel);
+ topicText = new Text(main, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
+ .applyTo(topicText);
+ topicText.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ checkPage();
+ }
+ });
+ topicLabel.addTraverseListener(new TraverseListener() {
+
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ topicText.setFocus();
+ topicText.selectAll();
+ }
+ });
+
+ useTopic.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ topicText.setEnabled(useTopic.getSelection());
+ checkPage();
+ }
+ });
+
// get all available Gerrit URIs from the repository
SortedSet<String> uris = new TreeSet<>();
try {
@@ -178,11 +254,29 @@ class PushToGerritPage extends WizardPage {
}
selectLastUsedUri();
setLastUsedBranch();
+ initializeTopic(branchText.getText());
+ addTopicProposal(topicText);
branchText.setFocus();
Dialog.applyDialogFont(main);
setControl(main);
}
+ private void loadKnownRemoteRefs() {
+ try {
+ Set<String> remotes = repository.getRefDatabase()
+ .getRefs(Constants.R_REMOTES).keySet();
+ for (String remote : remotes) {
+ // these are "origin/master", "origin/xxx"...
+ int slashIndex = remote.indexOf('/');
+ if (slashIndex > 0 && slashIndex < remote.length() - 1) {
+ knownRemoteRefs.add(remote.substring(slashIndex + 1));
+ }
+ }
+ } catch (IOException e) {
+ // simply ignore, no proposals and no topic check then
+ }
+ }
+
private void storeLastUsedUri(String uri) {
settings.put(lastUriKey, uri.trim());
}
@@ -191,6 +285,46 @@ class PushToGerritPage extends WizardPage {
settings.put(lastBranchKey, branch.trim());
}
+ private void storeLastUsedTopic(boolean enabled, String topic,
+ String branch) {
+ boolean isValid = validateTopic(topic) == null;
+ if (topic.equals(branch)) {
+ topic = null;
+ } else if (topic.isEmpty()) {
+ enabled = false;
+ } else if (isValid) {
+ topicProposals.put(topic, null);
+ settings.put(repository + LAST_TOPICS_POSTFIX, topicProposals
+ .keySet().toArray(new String[topicProposals.size()]));
+ }
+ if (branch != null && !ObjectId.isId(branch)) {
+ // Don't store on detached HEAD
+ StoredConfig config = repository.getConfig();
+ if (enabled) {
+ config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ GERRIT_TOPIC_USE_KEY, enabled);
+ } else {
+ config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ GERRIT_TOPIC_USE_KEY);
+ }
+ if (topic == null || topic.isEmpty()) {
+ config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ GERRIT_TOPIC_KEY);
+ } else if (isValid) {
+ config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ GERRIT_TOPIC_KEY, topic);
+ }
+ try {
+ config.save();
+ } catch (IOException e) {
+ Activator.logError(
+ NLS.bind(UIText.PushToGerritPage_TopicSaveFailure,
+ repository),
+ e);
+ }
+ }
+ }
+
private void selectLastUsedUri() {
String lastUri = settings.get(lastUriKey);
if (lastUri != null) {
@@ -221,6 +355,50 @@ class PushToGerritPage extends WizardPage {
}
}
+ private void initializeTopic(String remoteBranch) {
+ boolean enabled = false;
+ String storedTopic = null;
+ String branch = null;
+ try {
+ branch = repository.getBranch();
+ // On detached HEAD don't do anything: "Use topic" will be disabled
+ // and the topic field empty.
+ if (ObjectId.isId(branch)) {
+ branch = null;
+ }
+ } catch (final IOException e) {
+ Activator.logError(e.getLocalizedMessage(), e);
+ }
+ if (branch != null) {
+ StoredConfig config = repository.getConfig();
+ enabled = config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
+ branch, GERRIT_TOPIC_USE_KEY, false);
+ storedTopic = config.getString(
+ ConfigConstants.CONFIG_BRANCH_SECTION, branch,
+ GERRIT_TOPIC_KEY);
+ }
+ if (storedTopic == null || storedTopic.isEmpty()) {
+ if (branch != null && !branch.isEmpty()
+ && !branch.equals(remoteBranch)) {
+ topicText.setText(branch);
+ }
+ } else {
+ topicText.setText(storedTopic);
+ }
+ useTopic.setSelection(enabled);
+ topicText.setEnabled(enabled);
+ // Load topicProposals from settings.
+ String[] proposals = settings
+ .getArray(repository + LAST_TOPICS_POSTFIX);
+ if (proposals != null) {
+ for (int i = proposals.length - 1; i >= 0; i--) {
+ if (!proposals[i].isEmpty()) {
+ topicProposals.put(proposals[i], null);
+ }
+ }
+ }
+ }
+
private void checkPage() {
setErrorMessage(null);
try {
@@ -228,23 +406,78 @@ class PushToGerritPage extends WizardPage {
setErrorMessage(UIText.PushToGerritPage_MissingUriMessage);
return;
}
- if (branchText.getText().length() == 0) {
+ if (branchText.getText().trim().isEmpty()) {
setErrorMessage(UIText.PushToGerritPage_MissingBranchMessage);
return;
}
+ if (topicText.isEnabled()) {
+ setErrorMessage(validateTopic(topicText.getText().trim()));
+ }
} finally {
setPageComplete(getErrorMessage() == null);
}
}
+ private String validateTopic(String topic) {
+ if (WHITESPACE.matcher(topic).find()) {
+ return UIText.PushToGerritPage_TopicHasWhitespace;
+ }
+ if (topic.indexOf(',') >= 0) {
+ if (topic.indexOf('%') >= 0) {
+ return UIText.PushToGerritPage_TopicInvalidCharacters;
+ }
+ String withTopic = branchText.getText().trim();
+ int i = withTopic.indexOf('%');
+ if (i >= 0) {
+ withTopic = withTopic.substring(0, i);
+ }
+ withTopic += '/' + topic;
+ if (knownRemoteRefs.contains(withTopic)) {
+ return NLS.bind(UIText.PushToGerritPage_TopicCollidesWithBranch,
+ withTopic);
+ }
+ }
+ return null;
+ }
+
+ private String setTopicInRef(String ref, String topic) {
+ String baseRef;
+ String options;
+ int i = ref.indexOf('%');
+ if (i >= 0) {
+ baseRef = ref.substring(0, i);
+ options = ref.substring(i + 1);
+ options = options.replaceAll("topic=[^,]*", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ baseRef = ref;
+ options = ""; //$NON-NLS-1$
+ }
+ if (topic.indexOf(',') >= 0) {
+ // Cannot use %topic=, since Gerrit splits on commas
+ baseRef += '/' + topic;
+ } else {
+ if (!options.isEmpty()) {
+ options += ',';
+ }
+ options += "topic=" + topic; //$NON-NLS-1$
+ }
+ if (!options.isEmpty()) {
+ return baseRef + '%' + options;
+ }
+ return baseRef;
+ }
+
void doPush() {
try {
URIish uri = new URIish(uriCombo.getText());
- Ref currentHead = repository.getRef(Constants.HEAD);
+ Ref currentHead = repository.exactRef(Constants.HEAD);
+ String ref = prefixCombo.getItem(prefixCombo.getSelectionIndex())
+ + branchText.getText().trim();
+ if (topicText.isEnabled()) {
+ ref = setTopicInRef(ref, topicText.getText().trim());
+ }
RemoteRefUpdate update = new RemoteRefUpdate(repository,
- currentHead, prefixCombo.getItem(prefixCombo
- .getSelectionIndex()) + branchText.getText(),
- false, null, null);
+ currentHead, ref, false, null, null);
PushOperationSpecification spec = new PushOperationSpecification();
spec.addURIRefUpdates(uri, Arrays.asList(update));
@@ -267,6 +500,8 @@ class PushToGerritPage extends WizardPage {
op.getDestinationString(), false, false);
storeLastUsedUri(uriCombo.getText());
storeLastUsedBranch(branchText.getText());
+ storeLastUsedTopic(topicText.isEnabled(),
+ topicText.getText().trim(), repository.getBranch());
} catch (URISyntaxException e) {
Activator.handleError(e.getMessage(), e, true);
} catch (IOException e) {
@@ -279,7 +514,34 @@ class PushToGerritPage extends WizardPage {
}
}
+ private void addTopicProposal(Text textField) {
+ if (topicProposals.isEmpty()) {
+ return;
+ }
+ KeyStroke stroke = UIUtils.getKeystrokeOfBestActiveBindingFor(
+ IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST);
+ if (stroke != null) {
+ UIUtils.addBulbDecorator(textField,
+ NLS.bind(
+ UIText.PushToGerritPage_TopicContentProposalHoverText,
+ stroke.format()));
+ }
+ String[] recentTopics = topicProposals.keySet()
+ .toArray(new String[topicProposals.size()]);
+ Arrays.sort(recentTopics, CommonUtils.STRING_ASCENDING_COMPARATOR);
+ SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(
+ recentTopics);
+ proposalProvider.setFiltering(true);
+ ContentProposalAdapter adapter = new ContentProposalAdapter(textField,
+ new TextContentAdapter(), proposalProvider, stroke, null);
+ adapter.setProposalAcceptanceStyle(
+ ContentProposalAdapter.PROPOSAL_REPLACE);
+ }
+
private void addRefContentProposalToText(final Text textField) {
+ if (knownRemoteRefs.isEmpty()) {
+ return;
+ }
KeyStroke stroke = UIUtils
.getKeystrokeOfBestActiveBindingFor(IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST);
if (stroke != null)
@@ -320,24 +582,7 @@ class PushToGerritPage extends WizardPage {
pattern = null;
}
- Set<String> proposals = new TreeSet<>(
- String.CASE_INSENSITIVE_ORDER);
-
- try {
- Set<String> remotes = repository.getRefDatabase()
- .getRefs(Constants.R_REMOTES).keySet();
- for (String remote : remotes) {
- // these are "origin/master", "origin/xxx"...
- int slashIndex = remote.indexOf('/');
- if (slashIndex > 0 && slashIndex < remote.length() - 1)
- proposals
- .add(remote.substring(remote.indexOf('/') + 1));
- }
- } catch (IOException e) {
- // simply ignore, no proposals then
- }
-
- for (final String proposal : proposals) {
+ for (final String proposal : knownRemoteRefs) {
if (pattern != null && !pattern.matcher(proposal).matches())
continue;
IContentProposal propsal = new BranchContentProposal(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimpleConfigurePushDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimpleConfigurePushDialog.java
index f43ba3cc43..0481231f82 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimpleConfigurePushDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimpleConfigurePushDialog.java
@@ -673,7 +673,7 @@ public class SimpleConfigurePushDialog extends TitleAreaDialog {
Ref source;
try {
// TODO better checks for wild-cards and such
- source = repository.getRef(spec.getSource());
+ source = repository.findRef(spec.getSource());
} catch (IOException e1) {
source = null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogViewContentProvider.java
index 11ecaae656..501e74e2ff 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogViewContentProvider.java
@@ -69,9 +69,9 @@ public class ReflogViewContentProvider implements ITreeContentProvider {
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ReflogInput) {
ReflogInput input = (ReflogInput) inputElement;
- ReflogCommand command = new Git(input.repository).reflog();
- command.setRef(input.ref);
- try {
+ try (Git git = new Git(input.repository)) {
+ ReflogCommand command = git.reflog();
+ command.setRef(input.ref);
return command.call().toArray();
} catch (Exception e) {
Activator.logError("Error running reflog command", e); //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java
index efdbf26519..b1bc99e91d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchPage.java
@@ -396,7 +396,7 @@ class CreateBranchPage extends WizardPage {
myBaseCommit);
else
cbop = new CreateLocalBranchOperation(myRepository, newRefName,
- myRepository.getRef(this.sourceRefName),
+ myRepository.findRef(this.sourceRefName),
upstreamConfig);
cbop.execute(monitor);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java
index 83ce84e9b0..12e2fa00bb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/CreateBranchWizard.java
@@ -60,7 +60,7 @@ public class CreateBranchWizard extends Wizard {
if (base.startsWith(Constants.R_HEADS)
|| base.startsWith(Constants.R_REMOTES)
|| base.startsWith(Constants.R_TAGS)) {
- Ref currentBranch = repository.getRef(base);
+ Ref currentBranch = repository.exactRef(base);
myPage = new CreateBranchPage(repository, currentBranch);
} else {
// the page only knows some special Refs
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
index 2e9ebe1e9b..7b1e29d653 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
@@ -645,7 +645,7 @@ public class RepositoriesViewContentProvider implements ITreeContentProvider,
*/
private boolean hasStashedCommits(final Repository repository) {
try {
- return repository.getRef(Constants.R_STASH) != null;
+ return repository.exactRef(Constants.R_STASH) != null;
} catch (IOException e) {
return false;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewLabelProvider.java
index 4610e9dce5..af519466e6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewLabelProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewLabelProvider.java
@@ -288,7 +288,7 @@ public class RepositoriesViewLabelProvider extends ColumnLabelProvider
Ref head;
try {
- head = repository.getRef(Constants.HEAD);
+ head = repository.exactRef(Constants.HEAD);
} catch (IOException e) {
return string;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java
index 4403e6a84b..4cfd763987 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java
@@ -63,11 +63,11 @@ public class RepositoryStatisticsPage extends PropertyPage {
}
Repository repo = AdapterUtils.adapt(getElement(), Repository.class);
- if (repo == null)
+ if (repo == null) {
return table;
- Git git = new Git(repo);
- GarbageCollectCommand gc = git.gc();
- try {
+ }
+ try (Git git = new Git(repo)) {
+ GarbageCollectCommand gc = git.gc();
Properties stats = gc.getStatistics();
table.setLinesVisible(true);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java
index ce4516f598..182b4f4d7b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java
@@ -73,7 +73,8 @@ public class BranchHierarchyNode extends RepositoryTreeNode<IPath> {
int segmentDiff = myPath.segmentCount()
- getObject().segmentCount();
if (segmentDiff == 1) {
- Ref ref = getRepository().getRef(myPath.toPortableString());
+ Ref ref = getRepository()
+ .findRef(myPath.toPortableString());
childRefs.add(ref);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddToIndexCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddToIndexCommand.java
index cdcb75ea38..194579b790 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddToIndexCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddToIndexCommand.java
@@ -39,20 +39,21 @@ public class AddToIndexCommand extends
Repository repository = selectedNodes.get(0).getRepository();
IPath workTreePath = new Path(repository.getWorkTree().getAbsolutePath());
- AddCommand addCommand = new Git(repository).add();
+ try (Git git = new Git(repository)) {
+ AddCommand addCommand = git.add();
- Collection<IPath> paths = getSelectedFileAndFolderPaths(event);
- for (IPath path : paths) {
- String repoRelativepath;
- if (path.equals(workTreePath))
- repoRelativepath = "."; //$NON-NLS-1$
- else
- repoRelativepath = path.removeFirstSegments(
- path.matchingFirstSegments(workTreePath))
- .setDevice(null).toString();
- addCommand.addFilepattern(repoRelativepath);
- }
- try {
+ Collection<IPath> paths = getSelectedFileAndFolderPaths(event);
+ for (IPath path : paths) {
+ String repoRelativepath;
+ if (path.equals(workTreePath))
+ repoRelativepath = "."; //$NON-NLS-1$
+ else
+ repoRelativepath = path
+ .removeFirstSegments(
+ path.matchingFirstSegments(workTreePath))
+ .setDevice(null).toString();
+ addCommand.addFilepattern(repoRelativepath);
+ }
addCommand.call();
} catch (GitAPIException e) {
Activator.logError(UIText.AddToIndexCommand_addingFilesFailed,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteRepositoryConfirmDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteRepositoryConfirmDialog.java
index 4f059d177f..99183f9b9c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteRepositoryConfirmDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteRepositoryConfirmDialog.java
@@ -118,6 +118,8 @@ public class DeleteRepositoryConfirmDialog extends TitleAreaDialog {
} else
removeProjects.setVisible(false);
deleteGitDir.setFocus();
+ main.setTabList(
+ new Control[] { deleteGitDir, deleteWorkDir, removeProjects });
return main;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java
index d5dae759c5..2345710a14 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java
@@ -25,9 +25,9 @@ import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+import org.eclipse.ui.services.IServiceLocator;
/**
* Command to run jgit garbage collector
@@ -80,9 +80,14 @@ public class GarbageCollectCommand extends
return Status.OK_STATUS;
}
};
- IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
- IWorkbenchSiteProgressService service = CommonUtils.getService(activeSite, IWorkbenchSiteProgressService.class);
- service.schedule(job);
+ IServiceLocator serviceLocator = HandlerUtil.getActiveSite(event);
+ if (serviceLocator != null) {
+ IWorkbenchSiteProgressService service = CommonUtils.getService(
+ serviceLocator, IWorkbenchSiteProgressService.class);
+ service.schedule(job);
+ } else {
+ job.schedule();
+ }
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
index e5a62b6b3a..900ad40e91 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
@@ -56,10 +56,10 @@ import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+import org.eclipse.ui.services.IServiceLocator;
/**
* "Removes" one or several nodes
@@ -81,8 +81,12 @@ public class RemoveCommand extends
*/
protected void removeRepository(final ExecutionEvent event,
final boolean delete) {
- IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
- IWorkbenchSiteProgressService service = CommonUtils.getService(activeSite, IWorkbenchSiteProgressService.class);
+ IServiceLocator serviceLocator = HandlerUtil.getActiveSite(event);
+ IWorkbenchSiteProgressService service = null;
+ if (serviceLocator != null) {
+ service = CommonUtils.getService(serviceLocator,
+ IWorkbenchSiteProgressService.class);
+ }
// get selected nodes
final List<RepositoryNode> selectedNodes;
@@ -192,7 +196,11 @@ public class RemoveCommand extends
}
};
- service.schedule(job);
+ if (service == null) {
+ job.schedule();
+ } else {
+ service.schedule(job);
+ }
}
private void deleteProjects(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java
index 15ccd89b39..ac958d56d1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java
@@ -106,7 +106,7 @@ abstract class RepositoriesViewCommandHandler<T extends RepositoryTreeNode<?>>
private boolean repositoryHasHead(T treeNode) {
Repository repo = treeNode.getRepository();
try {
- Ref ref = repo.getRef(Constants.HEAD);
+ Ref ref = repo.exactRef(Constants.HEAD);
return ref != null && ref.getObjectId() != null;
} catch (IOException e) {
// ignore and report false
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java
index 69e603ab6e..33c47e8143 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java
@@ -14,7 +14,6 @@ package org.eclipse.egit.ui.internal.sharing;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -56,8 +55,6 @@ public class SharingWizard extends Wizard implements IConfigurationWizard,
private ExistingOrNewPage existingPage;
- private IWorkbenchPage activePage;
-
/**
* Construct the Git Sharing Wizard for connecting Git project to Eclipse
*/
@@ -85,7 +82,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard,
@Override
public boolean performFinish() {
- activePage = PlatformUI.getWorkbench()
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
if (!existingPage.getInternalMode()) {
try {
@@ -100,7 +97,8 @@ public class SharingWizard extends Wizard implements IConfigurationWizard,
InterruptedException {
for (Map.Entry<IProject, File> entry : projectsToMove
.entrySet()) {
- closeOpenEditorsForProject(entry.getKey());
+ closeOpenEditorsForProject(activePage,
+ entry.getKey());
IPath targetLocation = new Path(entry.getValue()
.getPath());
IPath currentLocation = entry.getKey()
@@ -189,41 +187,38 @@ public class SharingWizard extends Wizard implements IConfigurationWizard,
}
}
- private void closeOpenEditorsForProject(IProject project) {
- final List<IEditorReference> editorRefsToClose = new ArrayList<>();
- Map<IFile, IEditorReference> fileEditors = findAllEditorReferences();
- Set<IFile> keySet = fileEditors.keySet();
- for (IFile file : keySet) {
- if (file.getProject().equals(project)) {
- editorRefsToClose.add(fileEditors.get(file));
- }
- }
-
+ private void closeOpenEditorsForProject(final IWorkbenchPage activePage,
+ IProject project) {
+ final List<IEditorReference> editorRefsToClose = findEditorReferencesForProject(
+ activePage, project);
if (editorRefsToClose.isEmpty()) {
return;
}
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
@Override
public void run() {
-
- IEditorReference[] editorsToClose = new IEditorReference[editorRefsToClose
- .size()];
- editorsToClose = editorRefsToClose.toArray(editorsToClose);
- activePage.closeEditors(editorsToClose, true);
+ activePage.closeEditors(
+ editorRefsToClose.toArray(
+ new IEditorReference[editorRefsToClose.size()]),
+ true);
}
});
}
- private Map<IFile, IEditorReference> findAllEditorReferences() {
- IEditorReference[] editorReferences = activePage.getEditorReferences();
- Map<IFile, IEditorReference> fileEditors = new HashMap<>();
- for (IEditorReference editorReference : editorReferences) {
+ private List<IEditorReference> findEditorReferencesForProject(
+ IWorkbenchPage activePage, IProject project) {
+ List<IEditorReference> fileEditors = new ArrayList<>();
+ for (IEditorReference editorReference : activePage
+ .getEditorReferences()) {
try {
IEditorInput editorInput = editorReference.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
- fileEditors.put(file, editorReference);
+ if (file.getProject().equals(project)) {
+ fileEditors.add(editorReference);
+ }
}
} catch (PartInitException e) {
Activator.logError("PartInitException - should not happen", e); //$NON-NLS-1$
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 d6496b932f..b9a77f9349 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
@@ -1185,7 +1185,7 @@ public class StagingView extends ViewPart implements IShowInSource {
.getBoolean(UIPreferences.WARN_BEFORE_COMMITTING)
&& getPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT);
showControl(ignoreErrors, visible);
- ignoreErrors.getParent().layout(true);
+ mainSashForm.layout();
}
private int getProblemsSeverity() {
@@ -1275,7 +1275,7 @@ public class StagingView extends ViewPart implements IShowInSource {
String[] parts = s.split(","); //$NON-NLS-1$
int[] ints = new int[parts.length];
for (int i = 0; i < parts.length; i++) {
- ints[i] = Integer.valueOf(parts[i]).intValue();
+ ints[i] = Integer.parseInt(parts[i]);
}
return ints;
}
@@ -1553,6 +1553,7 @@ public class StagingView extends ViewPart implements IShowInSource {
if (isDisposed())
return;
enableCommitWidgets(enabled);
+ commitMessageText.setEnabled(enabled);
enableStagingWidgets(enabled);
}
@@ -1564,10 +1565,9 @@ public class StagingView extends ViewPart implements IShowInSource {
}
private void enableCommitWidgets(boolean enabled) {
- if (isDisposed())
+ if (isDisposed()) {
return;
-
- commitMessageText.setEnabled(enabled);
+ }
committerText.setEnabled(enabled);
enableAuthorText(enabled);
amendPreviousCommitAction.setEnabled(enabled);
@@ -2238,15 +2238,14 @@ public class StagingView extends ViewPart implements IShowInSource {
if (files.isEmpty() || repository == null) {
return;
}
- CheckoutCommand checkoutCommand = new Git(repository)
- .checkout();
- if (headRevision) {
- checkoutCommand.setStartPoint(Constants.HEAD);
- }
- for (String path : files) {
- checkoutCommand.addPath(path);
- }
- try {
+ try (Git git = new Git(repository)) {
+ CheckoutCommand checkoutCommand = git.checkout();
+ if (headRevision) {
+ checkoutCommand.setStartPoint(Constants.HEAD);
+ }
+ for (String path : files) {
+ checkoutCommand.addPath(path);
+ }
checkoutCommand.call();
if (!inaccessibleFiles.isEmpty()) {
IndexDiffCacheEntry indexDiffCacheForRepository = org.eclipse.egit.core.Activator
@@ -2505,7 +2504,7 @@ public class StagingView extends ViewPart implements IShowInSource {
private void stage(IStructuredSelection selection) {
StagingViewContentProvider contentProvider = getContentProvider(unstagedViewer);
- final Git git = new Git(currentRepository);
+ final Repository repository = currentRepository;
Iterator iterator = selection.iterator();
final List<String> addPaths = new ArrayList<>();
final List<String> rmPaths = new ArrayList<>();
@@ -2547,7 +2546,7 @@ public class StagingView extends ViewPart implements IShowInSource {
Job addJob = new Job(UIText.StagingView_AddJob) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- try {
+ try (Git git = new Git(repository)) {
AddCommand add = git.add();
for (String addPath : addPaths)
add.addFilepattern(addPath);
@@ -2576,7 +2575,7 @@ public class StagingView extends ViewPart implements IShowInSource {
Job removeJob = new Job(UIText.StagingView_RemoveJob) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- try {
+ try (Git git = new Git(repository)) {
RmCommand rm = git.rm().setCached(true);
for (String rmPath : rmPaths)
rm.addFilepattern(rmPath);
@@ -2632,12 +2631,12 @@ public class StagingView extends ViewPart implements IShowInSource {
if (paths.isEmpty())
return;
- final Git git = new Git(currentRepository);
+ final Repository repository = currentRepository;
Job resetJob = new Job(UIText.StagingView_ResetJob) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- try {
+ try (Git git = new Git(repository)) {
ResetCommand reset = git.reset();
for (String path : paths)
reset.addPath(path);
@@ -2970,18 +2969,18 @@ public class StagingView extends ViewPart implements IShowInSource {
private boolean hasErrorsOrWarnings() {
return getPreferenceStore()
.getBoolean(UIPreferences.WARN_BEFORE_COMMITTING)
- ? (getProblemsSeverity() >= Integer.valueOf(getPreferenceStore()
+ ? (getProblemsSeverity() >= Integer
+ .parseInt(getPreferenceStore()
.getString(UIPreferences.WARN_BEFORE_COMMITTING_LEVEL))
&& !ignoreErrors.getSelection()) : false;
}
- @SuppressWarnings("boxing")
private boolean isCommitBlocked() {
return getPreferenceStore()
.getBoolean(UIPreferences.WARN_BEFORE_COMMITTING)
&& getPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT)
? (getProblemsSeverity() >= Integer
- .valueOf(getPreferenceStore().getString(
+ .parseInt(getPreferenceStore().getString(
UIPreferences.BLOCK_COMMIT_LEVEL))
&& !ignoreErrors.getSelection())
: false;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 852b7387ce..8845345d6e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -916,6 +916,13 @@ PushToGerritPage_Message=Select a Gerrit URI and branch name
PushToGerritPage_MissingBranchMessage=Select a branch
PushToGerritPage_MissingUriMessage=Select a URI
PushToGerritPage_Title=Push the current HEAD from repository {0} to Gerrit
+PushToGerritPage_TopicCollidesWithBranch=Using this topic would collide with the remote branch ''{0}''
+PushToGerritPage_TopicContentProposalHoverText=Press {0} to see recently used topics beginning with the current topic text
+PushToGerritPage_TopicHasWhitespace=Topic must not contain whitespace
+PushToGerritPage_TopicInvalidCharacters=Topic must not contain both commas and percent signs
+PushToGerritPage_TopicLabel=&Topic:
+PushToGerritPage_TopicSaveFailure=Cannot save topic in configuration of ''{0}''
+PushToGerritPage_TopicUseLabel=Use Topic
PushToGerritPage_UriLabel=&URI:
PushToGerritWizard_Title=Push the current HEAD to Gerrit
@@ -1116,8 +1123,6 @@ BranchSelectionAndEditDialog_ErrorCouldNotCreateNewRef=Could not create new ref
BranchSelectionAndEditDialog_ErrorCouldNotDeleteRef=Could not delete ref {0}
BranchSelectionAndEditDialog_ErrorCouldNotRenameRef=Failed to rename branch {0} -> {1}, status={2}
BranchSelectionAndEditDialog_NewBranch=&New Branch...
-BranchSelectionAndEditDialog_QuestionNewBranchNameMessage=Enter new name of the {0} branch. {1} will be prepended to the name you type
-BranchSelectionAndEditDialog_QuestionNewBranchTitle=New branch
BranchSelectionAndEditDialog_Rename=&Rename...
BranchSelectionAndEditDialog_Delete=&Delete
MergeAction_CannotMerge=Merge Unavailable
diff --git a/org.eclipse.egit/META-INF/MANIFEST.MF b/org.eclipse.egit/META-INF/MANIFEST.MF
index 91bdced1c5..91baa0960d 100644
--- a/org.eclipse.egit/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin_name
-Bundle-SymbolicName: org.eclipse.egit
+Bundle-SymbolicName: org.eclipse.egit;singleton:=true
Bundle-Version: 4.4.0.qualifier
Bundle-Vendor: %provider_name
Bundle-Localization: plugin

Back to the top