Skip to main content
aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2022-02-06Commit message rewording: preview, sign-off, and change-idThomas Wolf1-1/+1
Use a CommitMessageComponent in the CommitMessageEditorDialog. Add a toolbar with the three buttons, a composite with a StackLayout containing the editable text viewer and the read-only previewer, and hook up everything. Bug: 440211 JGit-Dependency: I66a72e0646876d162a7011235cca969e20acf060 Change-Id: I907014b11fd479e187386af79d2f351d17165a95 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2022-02-01Clean commit messages consistently, and syntax-color comment linesThomas Wolf1-13/+3
Implement proper commit message cleaning according to git config "commit.cleanup". With the default git config, this changes the behavior of EGit: it now _does_ remove comment lines in commit messages by default. Previously, it didn't, except for squashing, where JGit did it unconditionally. Cleaning commit messages entered by the user in the UI is more consistent with the way C git behaves: it cleans messages obtained via an editor, but does not clean messages given on the command-line as in "git commit -m 'Some message'". To make the user aware of this new behavior, provide syntax coloring for comment lines in commit messages in the SpellcheckableMessageArea. Such syntax coloring makes only sense if the lines are indeed removed the message upon commit, so the implementation is only active for clean-up modes "strip" or "scissors".[1] For read-only display of commit messages, no syntax coloring of comment lines is done. The color used is configurable via the Eclipse preferences and is themeable. The default colors for the light and dark themes correspond to the default syntax coloring configuration of JDT for Java single- line comments. Since the staging view re-uses the same SpellcheckableMessageArea for multiple repositories, and the clean-up mode may be different between repositories, provide operations to change the clean-up mode of an existing SpellcheckableMessageArea and update the presentation. Change the interactive rebase InteractiveHandlers to the new interface InteractiveHandler2 to ensure this syntax coloring also works for rewording or squashing. There is no support (yet) for automatically updating the presentation in the SpellcheckableMessageArea when the git config changes. The view's refresh action does update the presentation, though. Switching between repositories also does so. Bug: 553065 Bug: 578173 JGit-Dependency: Ia0040c247884e684587dd45d6cb85f8b72a4b876 Change-Id: I07ceedcc781b50bde63805ff0bef9fde06902c80 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-10-01Resolve compiler warnings in the gitflow InitDialogThomas Wolf1-21/+22
Databinding code has been generified. Bug: 576358 Change-Id: I1026d2cc68556d6fed855f6c0b9791141779844c Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-09-29Don't use deprecated ImageDescriptor.getImageData()Thomas Wolf1-66/+8
EGit's own DecorationOverlayDescriptor is no longer necessary; the standard JFace DecorationOverlayIcon now can take an ImageDescriptor for the base image. In GitLightweightDecorator, adapt the CachedImageDescriptor to deal with zoom levels as in JFace's CompositeImageDescriptor. In GitFlowLightweightDecorator, don't do any caching at all. It decorates only repositories, so there should be no noticeable run-time effect since only a few items are decorated. Also simplify the code; there is no need to create a separate DecorationHelper object for this simple decoration. Change-Id: Ic1457941ac294b9c7f91d0ef660411f679bea2c7 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-09-29Don't use deprecated FilteredTree constructorThomas Wolf1-2/+1
Change-Id: Iee31c34990f581f6137a9489379546a3d5d4b325 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-09-02Handle long error messages in InputDialogThomas Wolf1-25/+9
Increase the height of the dialog if it isn't sufficient to show the whole error message. Do not make the dialog resizeable by the user; if the user _does_ resize the dialog, the layout is ugly: the message text above the input field grabs too much space. The dialog height is only increased, but never decreased, as that would lead to a constantly changing dialog when the user types and the validator returns messages of different lengths. Bug: 575695 Change-Id: I383090e9ce1b27dcb63d15b4c73beb17dd5d1b3f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-08-29Fix: Gitflow Start-Dialogs do not fully display long Error Messages.Max Hohenegger1-0/+5
Making start dialogs resizable enables users to read the full message. Bug: 575695 Change-Id: I958282e4631d5d5ab8b0723de88553e37dc7e28e Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2021-07-14Change singletons to enumeration literalsThomas Wolf2-2/+2
Use enumeration literals for the RepositoryCache, IndexDiffCache, RepositoryUtil, and RepositoryGroups singletons to ensure their initialization is thread-safe. Bug: 574806 Change-Id: I54def946ec3b708366c1f4b73f5aead531f0142b Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-03-11[osgi] Disperse the EGit core Activator into OSGi dynamic servicesThomas Wolf2-4/+5
Use OSGi DS to perform most of the setup formerly done in the Activator. Because of interdependencies it's not possible to do this step-by-step. The Activator did a number of unrelated things: * setting up the internal EGit caches (RepositoryCache, IndexDiffCache, RepositoryUtil). * setting up a number of IResourceChangeListeners for auto-sharing projects, auto-ignoring derived resources, and similar things. * setting up HTTP and SSH, and proxy support. * handling debug tracing options. * migrating preferences. * tracking merge strategies contributed via an extension point. Each of these have now become an OSGi DS component: * RepositoryInitializer: EGit caches * WorkspaceConnector: IResourceChangeListeners * TransportConfigurator: HTTP, SSH, and proxies * DebugOptionsHandler: debug tracing options * PreferencesMigrator: preferences migrations; runs as a Job * MergeStrategies: merge strategy tracking; runs a Job to initialize The activator is no longer the central hub from which other classes can obtain the RepositoryCache, IndexDiffCache, or RepositoryUtil. This change was necessary because otherwise an early component activation causes the Activator to run, which then might cause trying to activate org.eclipse.core.resources before the instance location is set, which breaks Eclipse start-up. These central singletons are newly managed in these three classes directly, and are accessible via getInstance() static methods. Likewise, the EGitSecureStore is now such a singleton that will be created on first access to the EGitSecureStore class. The RepositoryInitializer publishes the RepositoryCache as a service, which is consumed by the WorkspaceConnector OSGi component. This ensures correct initialization order. The changes outside the Activator and the six new OSGi components are all simple replacements for using the new instance getters instead of the Activator. Bug: 560412 Change-Id: Id5c7440213ae25a573e84720db7dfcc83a8f5d0a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-01-31Fix: Missing whitespace after branch name in UI text.Max Hohenegger1-1/+1
Gitflow init dialog would show "Branch 'xyz'does not..." Change-Id: I0794552c2e7b59ac4e05ce789fea1ea8a8ef88f3
2020-09-27Migrate remote connection timeout preference to EGit coreThomas Wolf4-15/+13
Migrate the value, if it is set, during the EGit core activator. Add an API class GitSettings to provide access to some core EGit settings. Bug: 563634 Change-Id: Ie854be26ca4bda5a32263599dd1a3f4531167d75 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-12-30Fix: Gitflow Publish is silent on failure.Max Hohenegger2-3/+51
Use regular EGit ShowPushResultAction to show error (and success) messages. Bug 493952 Change-Id: Ic733b58879d371966c287bbfc9c2a1dce2f18d7b
2019-12-26Gitflow start operations should support branch name normalization.Max Hohenegger1-1/+11
Bug 558538 Change-Id: I92c0ace32c2dd81fb1461dd7774bef78fc41d9cf
2019-11-16Prevent NPE in GitFlowLightweightDecoratorThomas Wolf1-2/+7
Change-Id: I82e0f965e2ef4bd88e9617dbb570058731902d02 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-11-12Decorators: cache more repository stateThomas Wolf2-63/+30
Generalize the mechanism previously only used for the branch state in the DecoratableResourceHelper. This cached the branch state per repository and relied on the label providers clearing that cache when needed. Use the same mechanism for more repository state, similar to what had been done in commit 8bf986c3 for handler enabling. Make RepositoryStateCache abstract; move the clearing on selection changes into a separate subclass and use that instead. Give decorators their own cache instance, and make sure they use it instead of computing things themselves over and over again. Bug: 550878 Change-Id: I988905103ad86e18c696269dd54d525fcdbc5cbc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-10-23Fix broken "start release" from commit in history viewMax Hohenegger2-18/+15
The changes in commit 2e2810f7 broke this sub-menu entry in Gitflow. Fix by using SelectionProvider instead of adapters. Add UI test to avoid future breakage. Bug: 551819 Change-Id: I943b43babc7d0eb028623c5419371fa68c4d8150 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-09-05Cache more repository state for re-use in the UI threadThomas Wolf1-19/+21
Many EGit commands depend on some repository state determining their enablement. Eclipse re-evaluates activation/enablement expressions or handlers' isEnabled() method very frequently. For globally available handlers, on every selection change; for others for instance when they are included in some (context) menu. JGit operations to determine repository state access the file system (typically config files, or the packed_refs file, or loose refs), and check every time whether the file has been changed since the last access. In the case of a repository config file, this check is even done for the user and system config files, too. If JGit determines that a file has been changed it reloads it, perhaps even multiple times depending on the file timestamp resolution. Thus accessing the repository config file or determining the currently checked out branch are expensive file system operations. Handler enablements are evaluated on the UI thread, so EGit did *a lot* of expensive file system accesses on the UI thread, which slows down Eclipse startup and context menus in particular. Introduce a cache for the most important values of a repository that are used in property testers and in handler activation and enablement code. The cache is cleared whenever the workbench selection or the "menu selection" changes to avoid serving stale values. When Eclipse then re-evaluates enablements, only the first expressions will actually access the file system, while all later re-evaluations due to a selection change will use the cached values. Caching values until the next selection change is a valid strategy. When a series of enablements is re-computed, these re-computations are all based on the same selection, thus using the repository state as it was at the beginning is fine. This greatly reduces the number of times EGit accesses the file system on the UI thread and generally makes the EGit UI *much* snappier. This cache should be used only for evaluations that are known to happen synchronously in the UI thread in response to a selection change. This includes property testers and isEnabled() on handlers. Bug: 544600 Change-Id: Idd369b50d8b4bd6dd68b30d640bbc13f5a5976c5 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-08-21Fix silent failure on conflicting checkout after branch creation.Max Hohenegger4-9/+67
* Minor changes in BranchOperationUI to re-use checkout result handling. * Add UI test because the issue is tedious to reproduce, and depends on proper synchronization with the Job and the Display thread. Bug 549612 Change-Id: I616b975f5eff881c6cc3455649ec7dd7a9bd293f Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2019-06-10Remove pre-Mars adapter workaroundMichael Keppler1-1/+2
Since our minimum target is Mars, we no longer need the previous workaround for avoiding compiler warnings around adapters. This is not a git revert, but an inline refactoring of the previously introduced method. Also inline AdapterUtils.adapt() in such a way that Adapters.adapt() is called instead. Bug:460685 Change-Id: Idbbe4853f68a9b6d1ffff1f434bdbfb9bc705a80 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-05-01Get display instance from workbenchMichael Keppler1-2/+3
org.eclipse.ui.IWorkbench.getDisplay() recommends to always use that method instead of Display.getDefault(). Change-Id: I0d7512aa9b40ad26e0b71356aa90bebd5b7611f7 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2019-04-14Always use 7 characters for short SHA1Michael Keppler2-2/+3
Use one common implementation to create short object ids. One visible change is that commit revision editors (opened from history etc.) now show 7 instead of 6 characters after the file name. Bug:544984 Change-Id: I3207b70b9fdba746ad5781d35a64fc54bb4782f2 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2019-03-21Handle expected value in property testersThomas Wolf1-2/+6
Derive all EGit property testers from AbstractPropertyTester and use its computeResult() method to match the computed value against the expected value. Replace negations of property tests in plugin.xml by value="false". Change-Id: I5b42653ee7fd60d49aa75cc39250eb30067c6490 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-03-18Use UIRepositoryUtils.showCleanupDialog()Thomas Wolf3-38/+10
Instead of creating CleanupUncommittedChangesDialogs in several places use the existing UIRepositoryUtils.showCleanupDialog(). This prepares unifying this dialog with the CheckoutConflictDialog. No functional changes. Bug: 545471 Change-Id: I299466f8486eae41e11c8b6c7b736a92ff4db8fd Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-03-17Gitflow: Validate branch name only different in caseMichael Keppler6-54/+49
Test whether the new branch name can be resolved in the repository already. That way we avoid trying to create branches with the same name (but different case) on case sensitive file systems. Using egit.core for input validation, and deprecated redundant code. Change-Id: I9cedb648ad0a8b640954fb26925255bbce2a5336 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu> Bug: 534616
2019-03-16Generify most getAdapter() methodsThomas Wolf1-26/+28
There are some overrides of getAdapter() inherited from platform compare which still inherit a non-generic signature in Eclipse Neon. But the large majority can finally be generified. Change-Id: I8b1b5e81e8d608d044bfd9d2c5d66569cb04e466 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-03-15Replace "Checkout" by "Check Out" when used as a verbThomas Wolf1-1/+1
There is no english verb "to checkout". It's "to check out". Change-Id: Ife96a5ce13a60a6bfd35a8745bd0488cb80cb15f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-19Fix typos in NLS keysMichael Keppler3-3/+3
During review of another change I noticed a triple character in an NLS key and did a search for all of them. Change-Id: If22bb13d61d405301607749bd5054c7df1f92263 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2019-02-17Avoid camelCase writing for workbenchMichael Keppler1-2/+2
Workbench is a single word, not two words separated by camelCase. Change-Id: Iedd910543f78142eb01175bed3df5cf1791ac167 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-10-21Use verbs instead of OKMichael Keppler11-6/+94
I went through typical UI and watched for dialogs still using OK. This is surely not exhaustive, but should at least cover many of the remaining typical operations. Wizard dialogs remain with the very generic "Finish", which we may want to think about, too. Bug: 538108 Change-Id: I2fec65a53a12c43d498546257c4e565cc2550341 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2018-10-17[gitflow] Honor gitflow.feature.start.fetch=trueMax Hohenegger1-1/+5
Using this option will cause Gitflow to fetch from the upstream repository before creating a new feature branch. The main benefit of this is that the check for diverging develop and origin/develop will always protect the user from creating a feature branch from an outdated develop state. Bug 539755 Change-Id: I84f7ef23db4f137ee710f78cea1d80211db762c0
2018-10-15Fixed: Gitflow ignores configured timeoutMax Hohenegger2-3/+3
Timeout is configured in EGit UI, not in Gitflow UI. Change-Id: I990e8b6482c3cc5fd157724e355e4f4c03e7a217
2018-08-13Fix filter in reflog viewMichael Keppler1-19/+3
The pattern filter uses the label provider of the viewer to match. However, tree viewers do not use a label provider at all (but column label providers). Therefore delegate the matching to the column label providers. Bug: 537492 Change-Id: I6865e4a29edec415a61499165003d6d753f22dfb Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-05-29Update license to EPL-2.0Matthias Sohn41-82/+164
Bug: 530393 Change-Id: Iea3b247253a97c28043187df0e35daecf518011e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-09-04Set window title in 'Init Git Flow' dialogMichael Keppler1-0/+1
All other dialogs in the gitflow plugin set the shell title correctly, as far as I inspected the code. Additionally I added an ellipsis to the "Init Git Flow" menu, since that one requires additional input from the user. There seems to be no corresponding test to be updated. Only the Eclipse wiki could be updated for the help generation when the change gets merged. Change-Id: Id95c327ff6e85811ec738ba8a51ce1c64260e440 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2017-03-16Add missing newlines at ends of Java filesDavid Pursehouse9-9/+9
Change-Id: Ibea4fae98811b36f0c56bcb88f858d008b2dd68a Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-11-02Fix incomplete null analysis configurationMax Hohenegger5-3/+19
JGit annotations were configured in the projects properties, but the dependency was unresolvable in the IDE. Hence null analysis was effectively disabled. Also fix potential null access that was revealed after the null analysis configuration has been fixed. Change-Id: I1f1e98ae14dbd1973e9fffe34475f072f460b728 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2016-09-05Check for running launches before modifying the workspaceThomas Wolf1-76/+10
Check before: * any checkout * any pull * any rebase, including when an interactive rebase is started * any merge * reset --hard * replace with ... * cherry-pick Bug: 495777 Change-Id: Ie7e325f363f4497f873694c419d5352fe269a89e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2016-08-29Added date time column to feature checkout dialogMax Hohenegger3-4/+36
The new column displays the time and date when the latest commit on a feature branch was last updated. Additionally, the table is now sorted after the new column, resulting in the last active branches being listed at the top. Change-Id: Id0fc08bcbf02323385b94f37e2a2fb356eda5cb0 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2016-06-20Merge "Cosmetic: Remove extraneous whitespace from table"Max Hohenegger1-1/+8
2016-06-20Merge "Make columns in Gitflow feature checkout dialog sortable"Max Hohenegger2-7/+106
2016-06-19Cosmetic: Remove extraneous whitespace from tableMax Hohenegger1-1/+8
Change-Id: If3ed0d09075f0a25464dea66c566bb37d865cc5e Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2016-06-18Make columns in Gitflow feature checkout dialog sortableMax Hohenegger2-7/+106
To make the dialog scale to many feature branches, it should support sorting. With the current set of columns this makes most sense if a a certain convention is used for either the feature names or the commit message, such as putting the ticket ID first. In the future, this could be used to sort by the date of the last commit on a branch. Change-Id: I9299ef2f882a3e4ea2bd2e8eff658419a10adbd9
2016-06-16Improved exception messageMax Hohenegger1-1/+2
Automated error reporting logged one instance of this ISE: 574cdfb6e4b00e8e334a5b28 There seems to be no issue with command enablement, though. Enabling the commands only if the develop branch exists, does not seem reasonable because a Gitflow repository with no develop branch is not a defined state. Change-Id: Ic8b01a2a150df75560c3ac9ddf35a9b80d05684b Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2016-05-19Merge branch 'stable-4.3'Matthias Sohn1-1/+2
* stable-4.3: Prepare 4.3.2-SNAPSHOT builds Ensure compatibility with pre-Mars Eclipse [releng] Importer fragment must have host bundle version constraint EGit v4.3.1.201605051710-r Change-Id: I470ee6a38fde58eb3a08677d336752b28d6911dc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-19Ensure compatibility with pre-Mars EclipseThomas Wolf1-1/+2
TreeViewer.getStructuredSelection() was introduced in Jface 3.11 only. Do not use it to ensure compatibility with olderJFace versions in older Eclipses. Bug: 493945 Change-Id: I1588a04a4b13ed4b6ee841262da78761d58dfcc0 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2016-05-18New convenience commands to compare/replace with Gitflow develop branchMax Hohenegger3-0/+192
When working on a feature or release branch, develop is the most common reference point for comparison. Hence, there should be a shortcut. Change-Id: I76e73bd6a7a9eb11a793fb2c628e7da81fa9b286 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
2016-05-15Mark current feature-branch and prevent attempted re-checkoutMax Hohenegger3-27/+94
Mark current branch with check symbol in Gitflow feature checkout dialog, and deactivate OK-button, if it is selected. This should make the dialog more consistent with other EGit branch selection UI. Change-Id: Iafcf345e3589af903c7a003c8f13df6166b80f3e Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-09Added columns to Gitflow feature branch selection widgetMax Hohenegger6-10/+71
New columns: CommitId and last commit message on branch. This is the same information that the standard checkout dialog provides, but by using columns instead of text decoration, more features, such as sorting, can be added later. Change-Id: Ie8cf98935c7e1cb4ad35032e8fe07c6f29cb15e4 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-03-22Test stability: fix FeatureFinishSquashTestThomas Wolf1-0/+1
The test didn't wait for the shell to open in AbstractFeatureFinishHandlerTest.finishFeature(). Unfortunately, that shell didn't have a title, and was thus a bit inconvenient to wait for. * Give that shell (a TitleAreaDialog) a title. TitleAreaDialog.setTitle() does not set the shell's title! * Simplify the code: use the async clickContextMenu instead of the sync variant wrapped in an asyncExec. Change-Id: I5e26490682821888b4f62da8a323cbc1aeeaded4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2016-03-13RepositoryCache: do not prematurely remove submodulesThomas Wolf2-4/+16
Basically we have no way of knowing when we no longer reference a repository. In our code alone, there may be RepositoryMappings and RepositoryNodes directly referencing a Repository, but some views may also have direct references to Repository instances. We therefore cannot explicitly remove repositories from the RepositoryCache, since we have no efficient and 100% reliable way to determine whether a Repository is still in use somewhere. Therefore the RepositoryCache relies on weak reference semantics. Before https://git.eclipse.org/r/#/c/62066/ , this whole mechanism was broken anyway because the IndexDiffCache had no way to remove an IndexDiffCacheEntry instance, and those instances had hard references to the Repository. So once there was an IndexDiffCacheEntry for a repository, that Repository instance would be kept forever. https://git.eclipse.org/r/#/c/62066/ itself was a wrong approach because it neglected that some repositories might never be "configured" repositories visible in the Repositories view. Such repositories would be removed from the RepositoryCache while still in use. Submodules and nested repositories are affected by this, but so can top-level repositories. The approach taken in this change here fixes this. First, we go back to relying solely on the weak reference semantics of the RepositoryCache. Note that doing so does not give any guarantee about when exactly a no longer used and only weakly reachable Repository instance will actually be removed from the cache. Then we at least make sure that we don't keep any hard references around. That's more difficult than it may seem: * Replaced all hard references to Repository in IndexDiffCacheEntry. We now only use the repository's git directory, and use that to get the repository from the RepositoryCache, if it still is there. * The oldIndex DirCache in an IndexDiffCacheEntry also had a hard reference to the Repository. Use a DirCache.read() variant that doesn't set that link -- it's used only for writing a DirCache, which we don't do. Note that this is a bit fragile as it relies on an implementation detail of JGit, but for now I see no other way. * Even worse, some Eclipse internals do keep around hard references to some "last selection"s. Those may contain no longer used RepositoryNodes from the repository view, which still reference the Repository instance through a hard reference. We have no real way to reliably ensure that these Eclipse internals forget those nodes. Therefore we have to ensure in RemoveCommand that we actually do null out these Repository references once we're sure we have removed the node from our view. (The two places I found where Eclipse holds on to such defunct nodes are WorkbenchSourceProvider.lastShowInSelection, set when the "Shown In..." context menu was last filled, and the CommonViewer, which also remembers the last selection.) * Our own RepositorySourceProvider had a private field referencing the last selected Repository. The RepositorySourceProvider is a singleton that is instantiated very early and then kept around forever. That was resolved by using a weak reference for the repository. * The EclipseContext also managed to (indirectly) hold on to a hard reference to a Repository instance through the context variable we provided. That was solved by not passing the Repository directly as the context variable defined by RepositorySourceProvider but again only the git directory. * RebaseInteractivePlan has a static global cache of plans and each plan had a hard reference to a repository. A plan is computed when the view is opened, even if never executed. That accumulated hard references to repositories. Solved by using a weak reference. * The Eclipse resource tree's DataTreeLookup has a static cache of instances that are re-used but not cleared after use. Those may keep references to our RepositoryMapping session properties for some time after the IResource to with the property was attached has gone. The test explicitly accounts for this. In the full test run in maven, more problems showed up in a heap dump taken just before we test for no cached repositories in GitRepositoriesViewRepoDeletionTest: numerous FileRepository instances from earlier tests were still referenced. * The EclipseContext retains some handler activations of ActionHamdlers of anonymous Action subclasses of SpellcheckableMessageArea, which reference the area through this$0, which itself keeps a reference to the CommitDialog through this$0, which means we keep the CommitMessageComponent, which has a hard reference to the Repository. Solved by using static subclasses that reference only the SourceViewer. * The Eclipse NavigationHistory keeps around references to some CommitEditorInputs, which also have a hard reference to a repository. * The synchronize view references a repository through its GitSynchronizeData. Resolved in test by keeping the synchronize view closed. * The FileRepository from testCompareWithPreviousWithMerge was still referenced from the job from CompareWithPreviousActionHandler even though no such job was running anymore. Referenced in the ProgressMonitorFocusJobDialog, which was still kept around through its fontChangeListener (an inner non-static class in the ultimate ancestor class Window), which apparently somehow was still registered.. Unclear why or what happened there. Not resolved. * Same thing with testRevertFailure; referenced from RevertCommitOperation from the job in RevertHandler from ProgressMonitorFocusJobDialog. Unresolved. * Anonymous actions in SwitchToMenu still reference a long gone repository from test method selectionWithProj1. Unclear why and unresolved. * Some repositories from earlier tests were still referenced through long defunct RepositoryNode instances. Unresolved. * RepositoryPropertySourceProvider has a hard reference to its lastObject, and the RepositoryPropertySource has hard references to the configs, which may have hard references to the Repository. Resolved in test by closing the property sheet; unresolved in general. Because we can't explicitly remove items from the RepositoryCache, we also cannot explicitly remove IndexDiffCache entries. The only thing we can do is to ensure we remove IndexDiffCacheEntries when we detect that a repository in the cache no longer exists (has been garbage collected, or its git directory no longer exists.) Additionally, the resource change listener of an IndexDiffCacheEntry unregisters itself when it finds its repository has gone. I cannot really claim that this still fixes bug 483664 because there is absolutely no way to ensure that repositories vanish from the RepositoryCache in a timely manner. But it's a best-effort attempt to at least try, and at the same time not to evict repositories from the cache prematurely. The test explicitly invokes System.gc() in an attempt to make the JVM actually reclaim weakly reachable objects. This is not guaranteed, but appears to work in practice: the test thus only shows that the obvious places where we kept hard references are indeed resolved, and the repository does indeed vanish eventually. But see the "unresolved" items above: there's no guarantee that some view or action handler or Eclipse internal class doesn't somehow still manages to keep a hard reference and thus prevent reclamation. Finally, testing for an empty RepositoryCache must ensure that the RepositoryChangeScanner does not interfere; otherwise that may temporarily hold hard references to repositories. Solved using a scheduling rule. Change-Id: I3f437caccd58d6c9fb4187f66d9f53e7834a5224 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>

Back to the top