diff options
author | James Moger <james.moger@gitblit.com> | 2015-03-07 11:52:14 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2015-03-07 11:52:14 -0500 |
commit | 5d59b9ba3206894198a24807690fba00844c98f7 (patch) | |
tree | 414273eb96ec5721b9c232bcc3f26375ed6651dd /src/main/java/com/gitblit/utils | |
parent | dd661a1091b2a59af513fc846293b6530e73f613 (diff) | |
download | gitblit-5d59b9ba3206894198a24807690fba00844c98f7.tar.gz gitblit-5d59b9ba3206894198a24807690fba00844c98f7.zip |
Add links to commit diff and blob diff pages to toggle whitespace setting
Diffstat (limited to 'src/main/java/com/gitblit/utils')
-rw-r--r-- | src/main/java/com/gitblit/utils/DiffUtils.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/java/com/gitblit/utils/DiffUtils.java b/src/main/java/com/gitblit/utils/DiffUtils.java index 458a4651..09b8f801 100644 --- a/src/main/java/com/gitblit/utils/DiffUtils.java +++ b/src/main/java/com/gitblit/utils/DiffUtils.java @@ -92,11 +92,11 @@ public class DiffUtils { * Enumeration for the diff comparator types.
*/
public static enum DiffComparator {
- DEFAULT(RawTextComparator.DEFAULT),
- WS_IGNORE_ALL(RawTextComparator.WS_IGNORE_ALL),
- WS_IGNORE_LEADING(RawTextComparator.WS_IGNORE_LEADING),
- WS_IGNORE_TRAILING(RawTextComparator.WS_IGNORE_TRAILING),
- WS_IGNORE_CHANGE(RawTextComparator.WS_IGNORE_CHANGE);
+ SHOW_WHITESPACE(RawTextComparator.DEFAULT),
+ IGNORE_WHITESPACE(RawTextComparator.WS_IGNORE_ALL),
+ IGNORE_LEADING(RawTextComparator.WS_IGNORE_LEADING),
+ IGNORE_TRAILING(RawTextComparator.WS_IGNORE_TRAILING),
+ IGNORE_CHANGES(RawTextComparator.WS_IGNORE_CHANGE);
public final RawTextComparator textComparator;
@@ -104,6 +104,14 @@ public class DiffUtils { this.textComparator = textComparator;
}
+ public DiffComparator getOpposite() {
+ return this == SHOW_WHITESPACE ? IGNORE_WHITESPACE : SHOW_WHITESPACE;
+ }
+
+ public String getTranslationKey() {
+ return "gb." + name().toLowerCase();
+ }
+
public static DiffComparator forName(String name) {
for (DiffComparator type : values()) {
if (type.name().equalsIgnoreCase(name)) {
@@ -371,7 +379,7 @@ public class DiffUtils { break;
}
df.setRepository(repository);
- df.setDiffComparator((comparator == null ? DiffComparator.DEFAULT : comparator).textComparator);
+ df.setDiffComparator((comparator == null ? DiffComparator.SHOW_WHITESPACE : comparator).textComparator);
df.setDetectRenames(true);
RevTree commitTree = commit.getTree();
|