* Enumeration for the diff comparator types.\r
*/\r
public static enum DiffComparator {\r
- DEFAULT(RawTextComparator.DEFAULT),\r
- WS_IGNORE_ALL(RawTextComparator.WS_IGNORE_ALL),\r
- WS_IGNORE_LEADING(RawTextComparator.WS_IGNORE_LEADING),\r
- WS_IGNORE_TRAILING(RawTextComparator.WS_IGNORE_TRAILING),\r
- WS_IGNORE_CHANGE(RawTextComparator.WS_IGNORE_CHANGE);\r
+ SHOW_WHITESPACE(RawTextComparator.DEFAULT),\r
+ IGNORE_WHITESPACE(RawTextComparator.WS_IGNORE_ALL),\r
+ IGNORE_LEADING(RawTextComparator.WS_IGNORE_LEADING),\r
+ IGNORE_TRAILING(RawTextComparator.WS_IGNORE_TRAILING),\r
+ IGNORE_CHANGES(RawTextComparator.WS_IGNORE_CHANGE);\r
\r
public final RawTextComparator textComparator;\r
\r
this.textComparator = textComparator;\r
}\r
\r
+ public DiffComparator getOpposite() {\r
+ return this == SHOW_WHITESPACE ? IGNORE_WHITESPACE : SHOW_WHITESPACE;\r
+ }\r
+\r
+ public String getTranslationKey() {\r
+ return "gb." + name().toLowerCase();\r
+ }\r
+\r
public static DiffComparator forName(String name) {\r
for (DiffComparator type : values()) {\r
if (type.name().equalsIgnoreCase(name)) {\r
break;\r
}\r
df.setRepository(repository);\r
- df.setDiffComparator((comparator == null ? DiffComparator.DEFAULT : comparator).textComparator);\r
+ df.setDiffComparator((comparator == null ? DiffComparator.SHOW_WHITESPACE : comparator).textComparator);\r
df.setDetectRenames(true);\r
\r
RevTree commitTree = commit.getTree();\r
gb.blinkComparator = Blink comparator
gb.imgdiffSubtract = Subtract (black = identical)
gb.deleteRepositoryHeader = Delete Repository
-gb.deleteRepositoryDescription = Deleted repositories will be unrecoverable.
\ No newline at end of file
+gb.deleteRepositoryDescription = Deleted repositories will be unrecoverable.
+gb.show_whitespace = show whitespace
+gb.ignore_whitespace = ignore whitespace
\ No newline at end of file
return new PageParameters(parameterMap);\r
}\r
\r
+ public static PageParameters newDiffParameter(String repositoryName,\r
+ String objectId, DiffComparator diffComparator) {\r
+ Map<String, String> parameterMap = new HashMap<String, String>();\r
+ if (StringUtils.isEmpty(objectId)) {\r
+ return newRepositoryParameter(repositoryName);\r
+ }\r
+ parameterMap.put("r", repositoryName);\r
+ parameterMap.put("h", objectId);\r
+ parameterMap.put("w", "" + diffComparator.ordinal());\r
+ return new PageParameters(parameterMap);\r
+ }\r
+\r
+ public static PageParameters newDiffParameter(String repositoryName,\r
+ String objectId, DiffComparator diffComparator, String blobPath) {\r
+ Map<String, String> parameterMap = new HashMap<String, String>();\r
+ if (StringUtils.isEmpty(objectId)) {\r
+ return newRepositoryParameter(repositoryName);\r
+ }\r
+ parameterMap.put("r", repositoryName);\r
+ parameterMap.put("h", objectId);\r
+ parameterMap.put("w", "" + diffComparator.ordinal());\r
+ parameterMap.put("f", blobPath);\r
+ return new PageParameters(parameterMap);\r
+ }\r
+\r
public static PageParameters newRangeParameter(String repositoryName,\r
String startRange, String endRange) {\r
Map<String, String> parameterMap = new HashMap<String, String>();\r
\r
<!-- blob nav links --> \r
<div class="page_nav2">\r
- <a wicket:id="blameLink"><wicket:message key="gb.blame"></wicket:message></a> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="commitDiffLink"><wicket:message key="gb.commitdiff"></wicket:message></a>\r
+ <a wicket:id="blameLink"><wicket:message key="gb.blame"></wicket:message></a> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="commitDiffLink"><wicket:message key="gb.commitdiff"></wicket:message></a> | <a wicket:id="whitespaceLink"></a>\r
</div> \r
\r
<!-- commit header -->\r
import com.gitblit.wicket.CacheControl.LastModified;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.CommitHeaderPanel;\r
+import com.gitblit.wicket.panels.LinkPanel;\r
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;\r
\r
@CacheControl(LastModified.BOOT)\r
WicketUtils.newObjectParameter(repositoryName, objectId)));\r
add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,\r
WicketUtils.newObjectParameter(repositoryName, objectId)));\r
+ add(new LinkPanel("whitespaceLink", null, getString(diffComparator.getOpposite().getTranslationKey()),\r
+ BlobDiffPage.class, WicketUtils.newDiffParameter(repositoryName, objectId, diffComparator.getOpposite(), blobPath)));\r
\r
// diff page links\r
add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,\r
\r
<!-- commitdiff nav links --> \r
<div class="page_nav2">\r
- <wicket:message key="gb.parent"></wicket:message>: <span wicket:id="parentLink">[parent link]</span> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a>\r
+ <wicket:message key="gb.parent"></wicket:message>: <span wicket:id="parentLink">[parent link]</span> | <a wicket:id="patchLink"><wicket:message key="gb.patch"></wicket:message></a> | <a wicket:id="commitLink"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="whitespaceLink"></a>\r
</div> \r
\r
<!-- commit header -->\r
public CommitDiffPage(PageParameters params) {
super(params);
- Repository r = getRepository();
-
- RevCommit commit = getCommit();
+ final Repository r = getRepository();
+ final RevCommit commit = getCommit();
+ final DiffComparator diffComparator = WicketUtils.getDiffComparator(params);
List<String> parents = new ArrayList<String>();
if (commit.getParentCount() > 0) {
WicketUtils.newObjectParameter(repositoryName, objectId)));
add(new BookmarkablePageLink<Void>("commitLink", CommitPage.class,
WicketUtils.newObjectParameter(repositoryName, objectId)));
+ add(new LinkPanel("whitespaceLink", null, getString(diffComparator.getOpposite().getTranslationKey()),
+ CommitDiffPage.class, WicketUtils.newDiffParameter(repositoryName, objectId, diffComparator.getOpposite())));
add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
final ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName,
parents.isEmpty() ? null : parents.get(0), commit.getName(), imageExtensions);
- final DiffComparator diffComparator = WicketUtils.getDiffComparator(params);
final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, diffComparator, DiffOutputType.HTML, handler);
if (handler.getImgDiffCount() > 0) {
addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs
Repository repository = GitBlitSuite.getHelloworldRepository();\r
RevCommit commit = JGitUtils.getCommit(repository,\r
"1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
- String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.DEFAULT, DiffOutputType.PLAIN).content;\r
+ String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;\r
repository.close();\r
assertTrue(diff != null && diff.length() > 0);\r
String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";\r
"8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");\r
RevCommit commit = JGitUtils.getCommit(repository,\r
"1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
- String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.DEFAULT, DiffOutputType.PLAIN).content;\r
+ String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;\r
repository.close();\r
assertTrue(diff != null && diff.length() > 0);\r
String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";\r
Repository repository = GitBlitSuite.getHelloworldRepository();\r
RevCommit commit = JGitUtils.getCommit(repository,\r
"1d0c2933a4ae69c362f76797d42d6bd182d05176");\r
- String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.DEFAULT, DiffOutputType.PLAIN).content;\r
+ String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;\r
repository.close();\r
assertTrue(diff != null && diff.length() > 0);\r
String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";\r