diff options
author | Matthias Sohn | 2018-06-13 23:08:27 +0000 |
---|---|---|
committer | Matthias Sohn | 2018-06-13 23:09:26 +0000 |
commit | 3a25cb61723b3461b3049210a6512633650b12b9 (patch) | |
tree | a53a88de1fca56830de6f205c4b87ca1f094d91d /org.eclipse.egit.ui | |
parent | fc34792f8068b7785181cd84236247589864399b (diff) | |
parent | d83b42807f460584ebc1767866a17c40f6d8c16a (diff) | |
download | egit-3a25cb61723b3461b3049210a6512633650b12b9.tar.gz egit-3a25cb61723b3461b3049210a6512633650b12b9.tar.xz egit-3a25cb61723b3461b3049210a6512633650b12b9.zip |
Merge branch 'stable-5.0'
* stable-5.0:
Prepare 5.0.1-SNAPSHOT builds
EGit v5.0.0.201806131550-r
Fix merge of wrong patchset of "EGit integration for LFS"
Prepare 5.0.0-SNAPSHOT builds
EGit v5.0.0.201806131210-r
Update documentation for 5.0
EGit integration for LFS
Downgrade Apache httpclient to 4.5.2.v20170210-0925
Handle new CommandFailedException when execution of ssh command fails
Fix target platform
Revert "Update staging view on repository config changes"
Update to latest Photon Orbit R20180606145124
Use hash lookup for TreeViewers
Prepare 5.0.0-SNAPSHOT builds
EGit v5.0.0.201806050710-rc3
Fix AssumeUnchangedOperation not working on directory/project
Change-Id: Ideee702514592028c5757b976237f35f4eea32bf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui')
17 files changed, 271 insertions, 31 deletions
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties index 6e9a0e0405..76e454f207 100644 --- a/org.eclipse.egit.ui/plugin.properties +++ b/org.eclipse.egit.ui/plugin.properties @@ -458,3 +458,5 @@ HistoryShowBlame.label=&Show Revision Information HistoryShowVersions.label=&Open RebaseInteractiveOpenInCommitViewer.label=&Open in Commit Viewer + +InstallLfsLocalCommand.label=Enable LFS locally
\ No newline at end of file diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml index 5049eb4389..86b0f3208d 100644 --- a/org.eclipse.egit.ui/plugin.xml +++ b/org.eclipse.egit.ui/plugin.xml @@ -1083,6 +1083,11 @@ </command> <command categoryId="org.eclipse.egit.ui.commandCategory" + id="org.eclipse.egit.ui.team.InstallLfsLocal" + name="%InstallLfsLocalCommand.label"> + </command> + <command + categoryId="org.eclipse.egit.ui.commandCategory" id="org.eclipse.egit.ui.team.Disconnect" name="%DisconnectCommand.name"> </command> @@ -2106,6 +2111,32 @@ </activeWhen> </handler> <handler + commandId="org.eclipse.egit.ui.team.InstallLfsLocal"> + <class + class="org.eclipse.egit.ui.internal.repository.tree.command.InstallLfsLocalCommand"> + </class> + <activeWhen> + <and> + <count + value="+"> + </count> + <iterate> + <and> + <instanceof + value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode"> + </instanceof> + <test + property="GitRepository.isSafe"> + </test> + <test + property="GitRepository.canEnableLfs"> + </test> + </and> + </iterate> + </and> + </activeWhen> + </handler> + <handler class="org.eclipse.egit.ui.internal.actions.UntrackActionHandler" commandId="org.eclipse.egit.ui.team.Untrack"> <activeWhen> @@ -4653,6 +4684,12 @@ </visibleWhen> </command> <command + commandId="org.eclipse.egit.ui.team.InstallLfsLocal" + label="%InstallLfsLocalCommand.label" + style="push"> + <visibleWhen checkEnabled="true" /> + </command> + <command commandId="org.eclipse.egit.ui.RepositoriesViewRemove" label="%RepoViewRemove.label" style="push"> @@ -6255,7 +6292,7 @@ class="org.eclipse.egit.ui.internal.repository.tree.RepositoriesViewPropertyTester" id="org.eclipse.egit.ui.RepositoryTester" namespace="GitRepository" - properties="isBare,isSafe,canCommit,canAmend,canResetHead,canStash,isRefCheckedOut,isLocalBranch,fetchExists,pushExists,canMerge,canAbortRebase,canContinueRebase,isSubmodule,containsHead,hasGerritConfiguration,canFetchFromGerrit,canPushToGerrit" + properties="isBare,isSafe,canCommit,canAmend,canResetHead,canStash,isRefCheckedOut,isLocalBranch,fetchExists,pushExists,canMerge,canAbortRebase,canContinueRebase,isSubmodule,containsHead,hasGerritConfiguration,canFetchFromGerrit,canPushToGerrit,canEnableLfs" type="org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode"> </propertyTester> <propertyTester diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java index 878ffff383..d46af6b077 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java @@ -110,6 +110,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer { store.setDefault(UIPreferences.SHOW_FETCH_POPUP_SUCCESS, true); store.setDefault(UIPreferences.SHOW_PUSH_POPUP_SUCCESS, true); store.setDefault(UIPreferences.SHOW_HOME_DIR_WARNING, true); + store.setDefault(UIPreferences.LFS_AUTO_CONFIGURATION, false); store.setDefault(UIPreferences.SHOW_DETACHED_HEAD_WARNING, true); store.setDefault(UIPreferences.SHOW_CHECKOUT_CONFIRMATION, true); store.setDefault(UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING, diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java index 3726a252da..b2bd9574ad 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java @@ -191,6 +191,8 @@ public class UIPreferences { /** */ public static final String SHOW_HOME_DIR_WARNING = "show_home_drive_warning"; //$NON-NLS-1$ /** */ + public static final String LFS_AUTO_CONFIGURATION = "auto_lfs_config"; //$NON-NLS-1$ + /** */ public static final String SHOW_DETACHED_HEAD_WARNING = "show_detached_head_warning"; //$NON-NLS-1$ /** */ public static final String SHOW_CHECKOUT_CONFIRMATION = "show_checkout_confirmation"; //$NON-NLS-1$ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ConfigurationChecker.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ConfigurationChecker.java index 23cf809b38..f856a150b6 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ConfigurationChecker.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ConfigurationChecker.java @@ -20,6 +20,11 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jgit.lib.ConfigConstants; +import org.eclipse.jgit.lib.StoredConfig; +import org.eclipse.jgit.util.FS; +import org.eclipse.jgit.util.LfsFactory; +import org.eclipse.jgit.util.LfsFactory.LfsInstallCommand; import org.eclipse.jgit.util.SystemReader; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.PlatformUI; @@ -31,8 +36,7 @@ import org.eclipse.ui.PlatformUI; public class ConfigurationChecker { /** - * Checks the system configuration. Currently only the HOME variable on - * Windows is checked + * Checks the system configuration. */ public static void checkConfiguration() { // Schedule a job @@ -61,6 +65,39 @@ public class ConfigurationChecker { private static void check() { checkHome(); + checkLfs(); + } + + private static void checkLfs() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + boolean auto = store.getBoolean(UIPreferences.LFS_AUTO_CONFIGURATION); + if (auto && !isLfsConfigured()) { + try { + LfsInstallCommand cmd = LfsFactory.getInstance() + .getInstallCommand(); + if (cmd != null) { + cmd.call(); + } + } catch (Exception e) { + Activator.handleIssue(IStatus.WARNING, + UIText.ConfigurationChecker_installLfsCannotInstall, e, + true); + } + } + } + + private static boolean isLfsConfigured() { + try { + StoredConfig cfg = SystemReader.getInstance().openUserConfig(null, + FS.DETECTED); + cfg.load(); + return cfg.getSubsections(ConfigConstants.CONFIG_FILTER_SECTION) + .contains("lfs"); //$NON-NLS-1$ + } catch (Exception e) { + Activator.handleIssue(IStatus.WARNING, + UIText.ConfigurationChecker_installLfsCannotLoadConfig, e, false); + } + return false; } private static void checkHome() { 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 ec072e1c9c..f472bc972f 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 @@ -712,6 +712,21 @@ public class UIText extends NLS { public static String GitPreferenceRoot_defaultMergeStrategyLabel; /** */ + public static String GitPreferenceRoot_lfsSupportCaption; + + /** */ + public static String GitPreferenceRoot_lfsSupportCaptionNotAvailable; + + /** */ + public static String GitPreferenceRoot_lfsSupportInstall; + + /** */ + public static String GitPreferenceRoot_lfsSupportSuccessMessage; + + /** */ + public static String GitPreferenceRoot_lfsSupportSuccessTitle; + + /** */ public static String ProcessStepsRebaseCommand_CancelDialogMessage; /** */ @@ -2446,6 +2461,12 @@ public class UIText extends NLS { public static String ConfigurationChecker_homeNotSet; /** */ + public static String ConfigurationChecker_installLfsCannotInstall; + + /** */ + public static String ConfigurationChecker_installLfsCannotLoadConfig; + + /** */ public static String ConfigurationEditorComponent_ConfigLocationLabel; /** */ @@ -3702,6 +3723,9 @@ public class UIText extends NLS { public static String RepositoriesViewLabelProvider_UnbornBranchText; /** */ + public static String DialogsPreferencePage_autoConfigureLfs; + + /** */ public static String DialogsPreferencePage_DetachedHeadCombo; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java index 5f5f06a9fe..835c61686b 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java @@ -390,7 +390,8 @@ public class BlameInformationControl extends AbstractInformationControl revision.getRepository(), revision.getSourcePath(), revision.getCommit(), parent, reader); if (diffEntry != null) { - FileDiff fileDiff = new FileDiff(revision.getCommit(), + FileDiff fileDiff = new FileDiff(revision.getRepository(), + revision.getCommit(), diffEntry); document.setDefault(revision.getRepository(), fileDiff); } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameRevision.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameRevision.java index 307773f05c..8922fc3d7b 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameRevision.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameRevision.java @@ -21,11 +21,11 @@ import org.eclipse.egit.core.internal.CompareCoreUtils; import org.eclipse.jface.text.revisions.Revision; import org.eclipse.jface.text.source.LineRange; import org.eclipse.jgit.diff.DiffAlgorithm; +import org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.diff.RawText; import org.eclipse.jgit.diff.RawTextComparator; -import org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm; import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; @@ -35,6 +35,7 @@ import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.util.LfsFactory; import org.eclipse.swt.graphics.RGB; /** @@ -213,8 +214,10 @@ public class BlameRevision extends Revision { if (diffEntry == null) return null; - RawText oldText = readText(diffEntry.getOldId(), reader); - RawText newText = readText(diffEntry.getNewId(), reader); + RawText oldText = readText(repository, diffEntry.getOldId(), reader, + diffEntry.getOldPath()); + RawText newText = readText(repository, diffEntry.getNewId(), reader, + diffEntry.getNewPath()); StoredConfig config = repository.getConfig(); DiffAlgorithm diffAlgorithm = DiffAlgorithm.getAlgorithm(config @@ -231,10 +234,11 @@ public class BlameRevision extends Revision { } } - private static RawText readText(AbbreviatedObjectId blobId, - ObjectReader reader) throws IOException { - ObjectLoader oldLoader = reader.open(blobId.toObjectId(), - Constants.OBJ_BLOB); + private static RawText readText(Repository db, AbbreviatedObjectId blobId, + ObjectReader reader, String path) throws IOException { + ObjectLoader oldLoader = LfsFactory.getInstance().applySmudgeFilter(db, + reader.open(blobId.toObjectId(), Constants.OBJ_BLOB), + LfsFactory.getAttributesForPath(db, path).get(Constants.ATTR_DIFF)); return new RawText(oldLoader.getCachedBytes()); } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java index cb282cf4cc..50a264f11b 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java @@ -65,6 +65,7 @@ public class DiffEditorOutlinePage extends NestedContentOutlinePage { super.createControl(parent); TreeViewer viewer = getTreeViewer(); viewer.setAutoExpandLevel(2); + viewer.setUseHashlookup(true); viewer.setContentProvider(new DiffContentProvider()); viewer.setLabelProvider(new DiffLabelProvider()); viewer.addDoubleClickListener( 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 76c51bad77..3ef42d654d 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 @@ -47,6 +47,7 @@ import org.eclipse.jgit.revwalk.RevTree; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.treewalk.CanonicalTreeParser; import org.eclipse.jgit.treewalk.TreeWalk; +import org.eclipse.jgit.util.LfsFactory; import org.eclipse.osgi.util.NLS; class GitDocument extends Document implements RefsChangedListener { @@ -220,7 +221,9 @@ class GitDocument extends Document implements RefsChangedListener { GitTraceLocation.getTrace().trace( GitTraceLocation.QUICKDIFF.getLocation(), "(GitDocument) compareTo: " + baseline); //$NON-NLS-1$ - ObjectLoader loader = repository.open(id, Constants.OBJ_BLOB); + ObjectLoader loader = LfsFactory.getInstance().applySmudgeFilter( + repository, repository.open(id, Constants.OBJ_BLOB), + tw.getAttributes().get(Constants.ATTR_DIFF)); byte[] bytes = loader.getBytes(); String charset; charset = CompareCoreUtils.getResourceEncoding(resource); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java index 9af04b54f0..b21f4b6b49 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java @@ -49,6 +49,7 @@ import org.eclipse.jgit.treewalk.EmptyTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.TreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilterMarker; +import org.eclipse.jgit.util.LfsFactory; import org.eclipse.ui.model.WorkbenchAdapter; /** @@ -82,6 +83,8 @@ public class FileDiff extends WorkbenchAdapter { private DiffEntry diffEntry; + private Repository repository; + static ObjectId[] trees(final RevCommit commit, final RevCommit[] parents) { final ObjectId[] r = new ObjectId[parents.length + 1]; for (int i = 0; i < r.length - 1; i++) @@ -152,7 +155,7 @@ public class FileDiff extends WorkbenchAdapter { List<DiffEntry> renames = detector.compute(walk.getObjectReader(), org.eclipse.jgit.lib.NullProgressMonitor.INSTANCE); for (DiffEntry m : renames) { - final FileDiff d = new FileDiff(commit, m); + final FileDiff d = new FileDiff(repository, commit, m); r.add(d); for (Iterator<DiffEntry> i = xentries.iterator(); i.hasNext();) { DiffEntry n = i.next(); @@ -163,7 +166,7 @@ public class FileDiff extends WorkbenchAdapter { } } for (DiffEntry m : xentries) { - final FileDiff d = new FileDiff(commit, m); + final FileDiff d = new FileDiff(repository, commit, m); r.add(d); } } @@ -180,7 +183,8 @@ public class FileDiff extends WorkbenchAdapter { int treeFilterMarks = treeFilterMarker.getMarks(walk); - final FileDiffForMerges d = new FileDiffForMerges(commit, + final FileDiffForMerges d = new FileDiffForMerges(repository, + commit, treeFilterMarks); d.path = walk.getPathString(); int m0 = 0; @@ -310,7 +314,10 @@ public class FileDiff extends WorkbenchAdapter { throws IOException { if (id.equals(ObjectId.zeroId())) return new RawText(new byte[] {}); - ObjectLoader ldr = reader.open(id, Constants.OBJ_BLOB); + ObjectLoader ldr = LfsFactory.getInstance().applySmudgeFilter(repository, + reader.open(id, Constants.OBJ_BLOB), + LfsFactory.getAttributesForPath(repository, getPath()) + .get(Constants.ATTR_DIFF)); return new RawText(ldr.getCachedBytes(Integer.MAX_VALUE)); } @@ -406,10 +413,14 @@ public class FileDiff extends WorkbenchAdapter { * Create a file diff for a specified {@link RevCommit} and * {@link DiffEntry} * + * @param repo + * * @param c * @param entry */ - public FileDiff(final RevCommit c, final DiffEntry entry) { + public FileDiff(final Repository repo, final RevCommit c, + final DiffEntry entry) { + repository = repo; diffEntry = entry; commit = c; } @@ -464,8 +475,9 @@ public class FileDiff extends WorkbenchAdapter { private final int treeFilterMarks; - private FileDiffForMerges(final RevCommit c, int treeFilterMarks) { - super (c, null); + private FileDiffForMerges(final Repository repo, final RevCommit c, + int treeFilterMarks) { + super(repo, c, null); this.treeFilterMarks = treeFilterMarks; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DialogsPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DialogsPreferencePage.java index 2fc0d35a66..2194dcb74e 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DialogsPreferencePage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DialogsPreferencePage.java @@ -79,6 +79,9 @@ public class DialogsPreferencePage extends FieldEditorPreferencePage implements UIPreferences.CLONE_WIZARD_SHOW_DETAILED_FAILURE_DIALOG, UIText.DialogsPreferencePage_ShowCloneFailedDialog, confirmDialogsGroup)); + addField(new BooleanFieldEditor(UIPreferences.LFS_AUTO_CONFIGURATION, + UIText.DialogsPreferencePage_autoConfigureLfs, + confirmDialogsGroup)); updateMargins(confirmDialogsGroup); Group infoGroup = new Group(main, SWT.SHADOW_ETCHED_IN); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java index 5113a4f263..bf251b05f1 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java @@ -24,6 +24,7 @@ import org.eclipse.egit.core.GitCorePreferences; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.preference.BooleanFieldEditor; @@ -33,6 +34,8 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IntegerFieldEditor; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.window.Window; +import org.eclipse.jgit.util.LfsFactory; +import org.eclipse.jgit.util.LfsFactory.LfsInstallCommand; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -250,6 +253,40 @@ public class GitPreferenceRoot extends DoublePreferencesPreferencePage addField(new BooleanFieldEditor(UIPreferences.CLONE_WIZARD_STORE_SECURESTORE, UIText.GitPreferenceRoot_SecureStoreUseByDefault, secureGroup)); updateMargins(secureGroup); + + boolean lfsAvailable = LfsFactory.getInstance().isAvailable() + && LfsFactory.getInstance().getInstallCommand() != null; + Group lfsGroup = new Group(main, SWT.SHADOW_ETCHED_IN); + GridLayoutFactory.fillDefaults().applyTo(lfsGroup); + GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1) + .applyTo(lfsGroup); + lfsGroup.setText( + lfsAvailable ? UIText.GitPreferenceRoot_lfsSupportCaption : UIText.GitPreferenceRoot_lfsSupportCaptionNotAvailable); + Button lfsEnable = new Button(lfsGroup, SWT.PUSH); + lfsEnable.setEnabled(lfsAvailable); + lfsEnable.setText(UIText.GitPreferenceRoot_lfsSupportInstall); + lfsEnable.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + // enable LFS support for user. + LfsInstallCommand cmd = LfsFactory.getInstance() + .getInstallCommand(); + try { + if (cmd != null) { + cmd.call(); + + MessageDialog.openInformation(getShell(), + UIText.GitPreferenceRoot_lfsSupportSuccessTitle, + UIText.GitPreferenceRoot_lfsSupportSuccessMessage); + } + } catch (Exception ex) { + Activator.handleError( + UIText.ConfigurationChecker_installLfsCannotInstall, + ex, true); + } + } + }); + updateMargins(lfsGroup); } private void updateMargins(Group group) { diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java index 770c0ddc64..0a828d75f6 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java @@ -24,6 +24,7 @@ import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.transport.RemoteConfig; +import org.eclipse.jgit.util.LfsFactory; /** * Property Tester used for enabling/disabling of context menus in the Git @@ -145,6 +146,13 @@ public class RepositoriesViewPropertyTester extends PropertyTester { return parent != null && parent.getType() == RepositoryTreeNodeType.SUBMODULES; } + + if ("canEnableLfs".equals(property)) { //$NON-NLS-1$ + if (LfsFactory.getInstance().isAvailable()) { + return !LfsFactory.getInstance().isEnabled(repository); + } + } + return false; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/InstallLfsLocalCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/InstallLfsLocalCommand.java new file mode 100644 index 0000000000..b4dc43eebc --- /dev/null +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/InstallLfsLocalCommand.java @@ -0,0 +1,71 @@ +/****************************************************************************** + * Copyright (c) 2018, Markus Duft <markus.duft@ssi-schaefer.com> + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *****************************************************************************/ +package org.eclipse.egit.ui.internal.repository.tree.command; + +import java.util.List; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.egit.ui.Activator; +import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode; +import org.eclipse.jgit.util.LfsFactory; +import org.eclipse.jgit.util.LfsFactory.LfsInstallCommand; + +/** + * Command to install LFS support in selected repositories. + */ +public class InstallLfsLocalCommand extends + RepositoriesViewCommandHandler<RepositoryNode> { + + /** + * Command id + */ + public static final String ID = "org.eclipse.egit.ui.team.InstallLfsLocal"; //$NON-NLS-1$ + + /** + * Execute installation + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + if (!LfsFactory.getInstance().isAvailable()) { + return null; + } + + // get selected nodes + final List<RepositoryNode> selectedNodes; + try { + selectedNodes = getSelectedNodes(event); + if (selectedNodes.isEmpty()) + return null; + } catch (ExecutionException e) { + Activator.handleError(e.getMessage(), e, true); + return null; + } + + for (RepositoryNode n : selectedNodes) { + try { + LfsInstallCommand cmd = LfsFactory.getInstance() + .getInstallCommand(); + if (cmd != null) { + cmd.setRepository(n.getRepository()).call(); + } + } catch (Exception e) { + Activator.handleError( + UIText.ConfigurationChecker_installLfsCannotInstall, e, + false); + } + } + + return null; + } + +} 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 ae17af6ec4..20946407d8 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 @@ -749,8 +749,6 @@ public class StagingView extends ViewPart private ListenerHandle refsChangedListener; - private ListenerHandle configChangedListener; - private LocalResourceManager resources = new LocalResourceManager( JFaceResources.getResources()); @@ -2044,6 +2042,7 @@ public class StagingView extends ViewPart Tree tree = toolkit.createTree(composite, SWT.FULL_SELECTION | SWT.MULTI); TreeViewer treeViewer = new TreeViewer(tree); + treeViewer.setUseHashlookup(true); return treeViewer; } @@ -3721,13 +3720,6 @@ public class StagingView extends ViewPart .addRefsChangedListener( event -> updateRebaseButtonVisibility(repository .getRepositoryState().isRebasing())); - if (configChangedListener != null) { - configChangedListener.remove(); - } - configChangedListener = repository.getListenerList() - .addConfigChangedListener( - event -> asyncExec( - () -> resetCommitMessageComponent())); } final StagingViewUpdate update = new StagingViewUpdate(repository, indexDiff, null); @@ -4281,9 +4273,6 @@ public class StagingView extends ViewPart if (refsChangedListener != null) { refsChangedListener.remove(); } - if (configChangedListener != null) { - configChangedListener.remove(); - } if (switchRepositoriesAction != null) { switchRepositoriesAction.dispose(); 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 27db53edc6..2f4e26de0b 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 @@ -256,6 +256,11 @@ GitPreferenceRoot_useLogicalModel=Allow models (e.g., Java, EMF) to participate GitPreferenceRoot_preferreMergeStrategy_label=You can select a specific merge strategy below\nto override the default JGit merge behavior for merge operations\n(merge, rebase, pull, revert, squash, stash, submodule update) GitPreferenceRoot_preferreMergeStrategy_group=Preferred merge strategy for operations that require merges GitPreferenceRoot_defaultMergeStrategyLabel=Default Strategy (as defined by JGit) +GitPreferenceRoot_lfsSupportCaption=LFS support +GitPreferenceRoot_lfsSupportCaptionNotAvailable=LFS support (not installed) +GitPreferenceRoot_lfsSupportInstall=Enable LFS support globally (for the current user) +GitPreferenceRoot_lfsSupportSuccessMessage=LFS support has been installed for the current user. +GitPreferenceRoot_lfsSupportSuccessTitle=LFS configured GitProjectPropertyPage_LabelBranch=Branch: GitProjectPropertyPage_LabelGitDir=Git directory: GitProjectPropertyPage_LabelId=HEAD: @@ -1312,6 +1317,7 @@ RepositoriesViewLabelProvider_SymbolicRefNodeText=References RepositoriesViewLabelProvider_TagsNodeText=Tags RepositoriesViewLabelProvider_UnbornBranchText=unborn branch; will be created on commit +DialogsPreferencePage_autoConfigureLfs=Automatically configure LFS without confirmation DialogsPreferencePage_DetachedHeadCombo=D&etached HEAD and checkout of remote-tracking branch DialogsPreferencePage_HideConfirmationGroupHeader=Show confirmation dialogs DialogsPreferencePage_ShowInfoGroupHeader=Show result dialogs after git remote operations @@ -1422,6 +1428,8 @@ user global configuration and to define the default location to store repositori not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and\n\ EGit might behave differently since they see different configuration options.\n\ This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. +ConfigurationChecker_installLfsCannotInstall=Cannot install LFS support +ConfigurationChecker_installLfsCannotLoadConfig=Cannot load user configuration ConfigurationEditorComponent_ConfigLocationLabel=&Location: ConfigurationEditorComponent_EmptyStringNotAllowed=Empty string is not allowed ConfigurationEditorComponent_KeyColumnHeader=Key |