summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHenning Heitkoetter2011-06-27 12:42:16 (EDT)
committer Chris Aniszczyk2011-06-27 15:22:18 (EDT)
commited2593d145541790bf070e5d7a6ae8fb4c428f81 (patch)
treea3a50e87bb12ba901a9ed513f88a019a38a7728c
parentddbd9e9f4cda94c8134a9e2e275853d0d5038ff9 (diff)
downloadegit-ed2593d145541790bf070e5d7a6ae8fb4c428f81.zip
egit-ed2593d145541790bf070e5d7a6ae8fb4c428f81.tar.gz
egit-ed2593d145541790bf070e5d7a6ae8fb4c428f81.tar.bz2
[blame] Add a preference to ignore whitespace changesrefs/changes/73/3773/4
This adds a git preference that controls if whitespace changes are to be ignored when calculating blame annotations from the context menu. If checked, use the WS_IGNORE_ALL text comparator instead of the default one when constructing the BlameCommand. Change-Id: Id22c3d5d0ca7f6603b47f1c71fdc182ea75a8527 Signed-off-by: Henning Heitkoetter <hheitkoetter@googlemail.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-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/UIText.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties2
6 files changed, 31 insertions, 3 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 a895271..d79298f 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
@@ -89,6 +89,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
GitChangeSetLabelProvider.DEFAULT_DATE_FORMAT);
store.setDefault(UIPreferences.HISTORY_MAX_NUM_COMMITS, 10000);
store.setDefault(UIPreferences.HISTORY_SHOW_TAG_SEQUENCE, false);
+ store.setDefault(UIPreferences.BLAME_IGNORE_WHITESPACE, false);
}
}
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 598e4af..9028ff9 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
@@ -145,6 +145,8 @@ public class UIPreferences {
public static final String STAGING_VIEW_SYNC_SELECTION = "StagingView_SyncWithSelection"; //$NON-NLS-1$
/** */
public static final String PAGE_COMMIT_PREFERENCES = "org.eclipse.egit.ui.internal.preferences.CommitDialogPreferencePage"; //$NON-NLS-1$
+ /** */
+ public static final String BLAME_IGNORE_WHITESPACE = "Blame_IgnoreWhitespace"; //$NON-NLS-1$
/**
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 9c0d19d..7c782ab 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -502,6 +502,12 @@ public class UIText extends NLS {
public static String GitPreferenceRoot_automaticallyEnableChangesetModel;
/** */
+ public static String GitPreferenceRoot_BlameGroupHeader;
+
+ /** */
+ public static String GitPreferenceRoot_BlameIgnoreWhitespaceLabel;
+
+ /** */
public static String GitPreferenceRoot_fetchBeforeSynchronization;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
index 22a95d7..618e660 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
@@ -20,9 +20,11 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.egit.core.op.IEGitOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.jface.text.revisions.RevisionInformation;
import org.eclipse.jgit.api.BlameCommand;
import org.eclipse.jgit.blame.BlameResult;
+import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.widgets.Shell;
@@ -69,11 +71,18 @@ public class BlameOperation implements IEGitOperation {
.getProject());
if (mapping == null)
return;
- BlameResult result = new BlameCommand(repository)
- .setFollowFileRenames(true)
- .setFilePath(mapping.getRepoRelativePath(file)).call();
+
+ final BlameCommand command = new BlameCommand(repository)
+ .setFollowFileRenames(true).setFilePath(
+ mapping.getRepoRelativePath(file));
+ if (Activator.getDefault().getPreferenceStore()
+ .getBoolean(UIPreferences.BLAME_IGNORE_WHITESPACE))
+ command.setTextComparator(RawTextComparator.WS_IGNORE_ALL);
+
+ final BlameResult result = command.call();
if (result == null)
return;
+
Map<RevCommit, BlameRevision> revisions = new HashMap<RevCommit, BlameRevision>();
int lineCount = result.getResultContents().size();
monitor.beginTask("", lineCount); //$NON-NLS-1$
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 6ac22de..bfb6e81 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
@@ -175,6 +175,14 @@ public class GitPreferenceRoot extends FieldEditorPreferencePage implements
UIText.GitPreferenceRoot_automaticallyEnableChangesetModel,
synchronizeGroup));
updateMargins(synchronizeGroup);
+
+ Group blameGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
+ GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1)
+ .applyTo(blameGroup);
+ blameGroup.setText(UIText.GitPreferenceRoot_BlameGroupHeader);
+ addField(new BooleanFieldEditor(UIPreferences.BLAME_IGNORE_WHITESPACE,
+ UIText.GitPreferenceRoot_BlameIgnoreWhitespaceLabel, blameGroup));
+ updateMargins(blameGroup);
}
private void updateMargins(Group group) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index aad6db9..c69c756 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -171,6 +171,8 @@ GitHistoryPage_IncompleteListTooltip=Not all commits are shown, the limit may be
GitHistoryPage_ListIncompleteWarningMessage=The list is incomplete
GitHistoryPage_ShowSubMenuLabel=&Show
GitPreferenceRoot_automaticallyEnableChangesetModel=Automatically enable chan&ge set grouping in Git synchronizations
+GitPreferenceRoot_BlameGroupHeader=Blame Annotations
+GitPreferenceRoot_BlameIgnoreWhitespaceLabel=Ignore whitespace changes
GitPreferenceRoot_fetchBeforeSynchronization=Always launch fetch before synchronization
GitPreferenceRoot_CloningRepoGroupHeader=Cloning repositories
GitPreferenceRoot_DefaultRepoFolderLabel=Default repository &folder: