From 5d59b9ba3206894198a24807690fba00844c98f7 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sat, 07 Mar 2015 11:52:14 -0500
Subject: [PATCH] Add links to commit diff and blob diff pages to toggle whitespace setting

---
 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 458a465..09b8f80 100644
--- a/src/main/java/com/gitblit/utils/DiffUtils.java
+++ b/src/main/java/com/gitblit/utils/DiffUtils.java
@@ -92,16 +92,24 @@
 	 * 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;
 
 		DiffComparator(RawTextComparator textComparator) {
 			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) {
@@ -371,7 +379,7 @@
 				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();

--
Gitblit v1.9.1