Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Duft2016-07-04 09:11:23 +0000
committerMatthias Sohn2018-06-13 14:54:19 +0000
commit9df32ed5010bd1cb6851f9385e494b205046fbca (patch)
treec1ef3619083899e4dbfb8bca7bf04e7aa7abd091 /org.eclipse.egit.ui/src/org/eclipse
parent908d32b8b181169532b30d53406e120e3500a95e (diff)
downloadegit-9df32ed5010bd1cb6851f9385e494b205046fbca.tar.gz
egit-9df32ed5010bd1cb6851f9385e494b205046fbca.tar.xz
egit-9df32ed5010bd1cb6851f9385e494b205046fbca.zip
EGit integration for LFS
* Register builtin LFS on startup When EGit starts and the lfs bundle (org.eclipse.jgit.lfs) is available register the LFS implementation and check configuration. * Allow install (enablement) of LFS support in Preferences (global) and on the repository (local). * Apply smudge/clean filters where applicable and required. * LFS integration using built-in JGit lfs filters fully works when using Gerrit with lfs plugin using ssh protocol. * Pushing lfs objects over http still fails with 401 response code, this is tracked in JGit bug 535814 Change-Id: I465da0f1c7f88272d3ec0e6545eea582eae631ec Also-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ConfigurationChecker.java41
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java24
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameInformationControl.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameRevision.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java26
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DialogsPreferencePage.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java37
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewPropertyTester.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/InstallLfsLocalCommand.java71
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties8
14 files changed, 245 insertions, 25 deletions
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/CompareUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
index 56cdd065b5..d45732baea 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
@@ -68,6 +68,7 @@ import org.eclipse.egit.ui.internal.synchronize.compare.LocalNonWorkspaceTypedEl
import org.eclipse.jface.action.Action;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.attributes.Attributes;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheCheckout.CheckoutMetadata;
import org.eclipse.jgit.dircache.DirCacheEditor;
@@ -92,6 +93,8 @@ import org.eclipse.jgit.treewalk.filter.NotIgnoredFilter;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.treewalk.filter.TreeFilter;
import org.eclipse.jgit.util.IO;
+import org.eclipse.jgit.util.LfsFactory;
+import org.eclipse.jgit.util.LfsFactory.LfsInputStream;
import org.eclipse.jgit.util.io.EolStreamTypeUtil;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
@@ -1102,15 +1105,21 @@ public class CompareUtils {
if (ent.getFileMode() != FileMode.REGULAR_FILE)
ent.setFileMode(FileMode.REGULAR_FILE);
- ent.setLength(content.limit());
ent.setLastModified(System.currentTimeMillis());
try {
- ByteArrayInputStream in = new ByteArrayInputStream(
- content.array(), 0, content.limit());
- ent.setObjectId(
- inserter.insert(Constants.OBJ_BLOB, content.limit(),
- in));
- inserter.flush();
+ Attributes attr = LfsFactory.getAttributesForPath(repo,
+ ent.getPathString());
+ try (LfsInputStream lfs = LfsFactory.getInstance()
+ .applyCleanFilter(repo,
+ new ByteArrayInputStream(content.array(), 0,
+ content.limit()),
+ content.limit(),
+ attr.get(Constants.ATTR_MERGE))) {
+ ent.setLength(lfs.getLength());
+ ent.setObjectId(inserter.insert(Constants.OBJ_BLOB,
+ lfs.getLength(), lfs));
+ inserter.flush();
+ }
} catch (IOException ex) {
throw new RuntimeException(ex);
}
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 cacf395d37..0e2342c679 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;
/** */
@@ -3699,6 +3720,9 @@ public class UIText extends NLS {
public static String RepositoriesViewLabelProvider_TagsNodeText;
/** */
+ 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/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/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 704e466720..8ded3f8322 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:
@@ -1311,6 +1316,7 @@ RepositoriesViewLabelProvider_SubmodulesNodeText=Submodules
RepositoriesViewLabelProvider_SymbolicRefNodeText=References
RepositoriesViewLabelProvider_TagsNodeText=Tags
+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
@@ -1421,6 +1427,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

Back to the top