From e41e8f8c3bc9f5edab1d271464364f95620ece8c Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 19 Nov 2015 17:55:38 -0500 Subject: [PATCH] Create filestore directory on startup --- src/main/java/com/gitblit/utils/DiffUtils.java | 61 +++++++++++++++++++----------- 1 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gitblit/utils/DiffUtils.java b/src/main/java/com/gitblit/utils/DiffUtils.java index 458a465..cdebec1 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) { @@ -221,11 +229,12 @@ * @param commit * @param comparator * @param outputType + * @param tabLength * @return the diff */ public static DiffOutput getCommitDiff(Repository repository, RevCommit commit, - DiffComparator comparator, DiffOutputType outputType) { - return getDiff(repository, null, commit, null, comparator, outputType); + DiffComparator comparator, DiffOutputType outputType, int tabLength) { + return getDiff(repository, null, commit, null, comparator, outputType, tabLength); } /** @@ -238,11 +247,12 @@ * @param handler * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}. * May be {@code null}, resulting in the default behavior. + * @param tabLength * @return the diff */ public static DiffOutput getCommitDiff(Repository repository, RevCommit commit, - DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler) { - return getDiff(repository, null, commit, null, comparator, outputType, handler); + DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler, int tabLength) { + return getDiff(repository, null, commit, null, comparator, outputType, handler, tabLength); } @@ -255,11 +265,12 @@ * @param path * @param comparator * @param outputType + * @param tabLength * @return the diff */ public static DiffOutput getDiff(Repository repository, RevCommit commit, String path, - DiffComparator comparator, DiffOutputType outputType) { - return getDiff(repository, null, commit, path, comparator, outputType); + DiffComparator comparator, DiffOutputType outputType, int tabLength) { + return getDiff(repository, null, commit, path, comparator, outputType, tabLength); } /** @@ -274,11 +285,12 @@ * @param handler * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}. * May be {@code null}, resulting in the default behavior. + * @param tabLength * @return the diff */ public static DiffOutput getDiff(Repository repository, RevCommit commit, String path, - DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler) { - return getDiff(repository, null, commit, path, comparator, outputType, handler); + DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler, int tabLength) { + return getDiff(repository, null, commit, path, comparator, outputType, handler, tabLength); } /** @@ -289,11 +301,13 @@ * @param commit * @param comparator * @param outputType + * @param tabLength + * * @return the diff */ public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit, - DiffComparator comparator, DiffOutputType outputType) { - return getDiff(repository, baseCommit, commit, null, comparator, outputType); + DiffComparator comparator, DiffOutputType outputType, int tabLength) { + return getDiff(repository, baseCommit, commit, null, comparator, outputType, tabLength); } /** @@ -307,11 +321,12 @@ * @param handler * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}. * May be {@code null}, resulting in the default behavior. + * @param tabLength * @return the diff */ public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit, - DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler) { - return getDiff(repository, baseCommit, commit, null, comparator, outputType, handler); + DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler, int tabLength) { + return getDiff(repository, baseCommit, commit, null, comparator, outputType, handler, tabLength); } /** @@ -327,11 +342,12 @@ * or folder. if unspecified, the diff is for the entire commit. * @param outputType * @param diffComparator + * @param tabLength * @return the diff */ public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit, - String path, DiffComparator diffComparator, DiffOutputType outputType) { - return getDiff(repository, baseCommit, commit, path, diffComparator, outputType, null); + String path, DiffComparator diffComparator, DiffOutputType outputType, int tabLength) { + return getDiff(repository, baseCommit, commit, path, diffComparator, outputType, null, tabLength); } /** @@ -350,10 +366,11 @@ * @param handler * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}. * May be {@code null}, resulting in the default behavior. + * @param tabLength * @return the diff */ public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit, String path, - DiffComparator comparator, DiffOutputType outputType, final BinaryDiffHandler handler) { + DiffComparator comparator, DiffOutputType outputType, final BinaryDiffHandler handler, int tabLength) { DiffStat stat = null; String diff = null; try { @@ -362,7 +379,7 @@ DiffFormatter df; switch (outputType) { case HTML: - df = new GitBlitDiffFormatter(commit.getName(), path, handler); + df = new GitBlitDiffFormatter(commit.getName(), path, handler, tabLength); break; case PLAIN: default: @@ -371,7 +388,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