Merged #233 "Ignore whitespace in diff viewer"
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * Enumeration for the diff comparator types.
|
| | | */
|
| | | public static enum DiffComparator {
|
| | | 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) {
|
| | | for (DiffComparator type : values()) {
|
| | | if (type.name().equalsIgnoreCase(name)) {
|
| | | return type;
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * Encapsulates the output of a diff.
|
| | | */
|
| | | public static class DiffOutput implements Serializable {
|
| | |
| | | *
|
| | | * @param repository
|
| | | * @param commit
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getCommitDiff(Repository repository, RevCommit commit,
|
| | | DiffOutputType outputType) {
|
| | | return getDiff(repository, null, commit, null, outputType);
|
| | | DiffComparator comparator, DiffOutputType outputType) {
|
| | | return getDiff(repository, null, commit, null, comparator, outputType);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | *
|
| | | * @param repository
|
| | | * @param commit
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @param handler
|
| | | * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}.
|
| | |
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getCommitDiff(Repository repository, RevCommit commit,
|
| | | DiffOutputType outputType, BinaryDiffHandler handler) {
|
| | | return getDiff(repository, null, commit, null, outputType, handler);
|
| | | DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler) {
|
| | | return getDiff(repository, null, commit, null, comparator, outputType, handler);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | * @param repository
|
| | | * @param commit
|
| | | * @param path
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit commit, String path,
|
| | | DiffOutputType outputType) {
|
| | | return getDiff(repository, null, commit, path, outputType);
|
| | | DiffComparator comparator, DiffOutputType outputType) {
|
| | | return getDiff(repository, null, commit, path, comparator, outputType);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param repository
|
| | | * @param commit
|
| | | * @param path
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @param handler
|
| | | * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}.
|
| | |
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit commit, String path,
|
| | | DiffOutputType outputType, BinaryDiffHandler handler) {
|
| | | return getDiff(repository, null, commit, path, outputType, handler);
|
| | | DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler) {
|
| | | return getDiff(repository, null, commit, path, comparator, outputType, handler);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param repository
|
| | | * @param baseCommit
|
| | | * @param commit
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit,
|
| | | DiffOutputType outputType) {
|
| | | return getDiff(repository, baseCommit, commit, null, outputType);
|
| | | DiffComparator comparator, DiffOutputType outputType) {
|
| | | return getDiff(repository, baseCommit, commit, null, comparator, outputType);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param repository
|
| | | * @param baseCommit
|
| | | * @param commit
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @param handler
|
| | | * to use for rendering binary diffs if {@code outputType} is {@link DiffOutputType#HTML HTML}.
|
| | |
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit,
|
| | | DiffOutputType outputType, BinaryDiffHandler handler) {
|
| | | return getDiff(repository, baseCommit, commit, null, outputType, handler);
|
| | | DiffComparator comparator, DiffOutputType outputType, BinaryDiffHandler handler) {
|
| | | return getDiff(repository, baseCommit, commit, null, comparator, outputType, handler);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * if the path is specified, the diff is restricted to that file
|
| | | * or folder. if unspecified, the diff is for the entire commit.
|
| | | * @param outputType
|
| | | * @param diffComparator
|
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit,
|
| | | String path, DiffOutputType outputType) {
|
| | | return getDiff(repository, baseCommit, commit, path, outputType, null);
|
| | | String path, DiffComparator diffComparator, DiffOutputType outputType) {
|
| | | return getDiff(repository, baseCommit, commit, path, diffComparator, outputType, null);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param path
|
| | | * if the path is specified, the diff is restricted to that file
|
| | | * or folder. if unspecified, the diff is for the entire commit.
|
| | | * @param comparator
|
| | | * @param outputType
|
| | | * @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.
|
| | | * @return the diff
|
| | | */
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit, String path, DiffOutputType outputType,
|
| | | final BinaryDiffHandler handler) {
|
| | | public static DiffOutput getDiff(Repository repository, RevCommit baseCommit, RevCommit commit, String path,
|
| | | DiffComparator comparator, DiffOutputType outputType, final BinaryDiffHandler handler) {
|
| | | DiffStat stat = null;
|
| | | String diff = null;
|
| | | try {
|
| | | ByteArrayOutputStream os = null;
|
| | | RawTextComparator cmp = RawTextComparator.DEFAULT;
|
| | |
|
| | | DiffFormatter df;
|
| | | switch (outputType) {
|
| | | case HTML:
|
| | |
| | | break;
|
| | | }
|
| | | df.setRepository(repository);
|
| | | df.setDiffComparator(cmp);
|
| | | df.setDiffComparator((comparator == null ? DiffComparator.SHOW_WHITESPACE : comparator).textComparator);
|
| | | df.setDetectRenames(true);
|
| | |
|
| | | RevTree commitTree = commit.getTree();
|
| | |
| | | */ |
| | | private static final int GLOBAL_DIFF_LIMIT = 20000; |
| | | |
| | | private static final boolean CONVERT_TABS = true; |
| | | |
| | | private final DiffOutputStream os; |
| | | |
| | | private final DiffStat diffStat; |
| | |
| | | // Highlight trailing whitespace on deleted/added lines. |
| | | Matcher matcher = trailingWhitespace.matcher(line); |
| | | if (matcher.find()) { |
| | | StringBuilder result = new StringBuilder(StringUtils.escapeForHtml(line.substring(0, matcher.start()), false)); |
| | | StringBuilder result = new StringBuilder(StringUtils.escapeForHtml(line.substring(0, matcher.start()), CONVERT_TABS)); |
| | | result.append("<span class='trailingws-").append(prefix == '+' ? "add" : "sub").append("'>"); |
| | | result.append(StringUtils.escapeForHtml(matcher.group(1), false)); |
| | | result.append("</span>"); |
| | | return result.toString(); |
| | | } |
| | | } |
| | | return StringUtils.escapeForHtml(line, false); |
| | | return StringUtils.escapeForHtml(line, CONVERT_TABS); |
| | | } |
| | | |
| | | /** |
| | |
| | | } else { |
| | | sb.append("<th class='diff-state diff-state-sub'></th><td class=\"diff-cell remove2\">"); |
| | | } |
| | | line = StringUtils.escapeForHtml(line.substring(1), false); |
| | | line = StringUtils.escapeForHtml(line.substring(1), CONVERT_TABS); |
| | | } |
| | | sb.append(line); |
| | | if (gitLinkDiff) { |
| | |
| | | gb.imgdiffSubtract = Subtract (black = identical) |
| | | gb.deleteRepositoryHeader = Delete Repository |
| | | gb.deleteRepositoryDescription = Deleted repositories will be unrecoverable. |
| | | gb.show_whitespace = show whitespace |
| | | gb.ignore_whitespace = ignore whitespace |
| | |
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.Metric;
|
| | | import com.gitblit.utils.DiffUtils.DiffComparator;
|
| | | import com.gitblit.utils.HttpUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.TimeUtils;
|
| | |
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newDiffParameter(String repositoryName,
|
| | | String objectId, DiffComparator diffComparator) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | parameterMap.put("w", "" + diffComparator.ordinal());
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newDiffParameter(String repositoryName,
|
| | | String objectId, DiffComparator diffComparator, String blobPath) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | parameterMap.put("w", "" + diffComparator.ordinal());
|
| | | parameterMap.put("f", blobPath);
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newRangeParameter(String repositoryName,
|
| | | String startRange, String endRange) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | |
| | | return params.getString("st", null);
|
| | | }
|
| | |
|
| | | public static DiffComparator getDiffComparator(PageParameters params) {
|
| | | int ordinal = params.getInt("w", 0);
|
| | | return DiffComparator.values()[ordinal];
|
| | | }
|
| | |
|
| | | public static int getPage(PageParameters params) {
|
| | | // index from 1
|
| | | return params.getInt("pg", 1);
|
| | |
| | |
|
| | | <!-- blob nav links -->
|
| | | <div class="page_nav2">
|
| | | <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="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>
|
| | | </div>
|
| | |
|
| | | <!-- commit header -->
|
| | |
| | |
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.utils.DiffUtils;
|
| | | import com.gitblit.utils.DiffUtils.DiffComparator;
|
| | | import com.gitblit.utils.DiffUtils.DiffOutputType;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
| | | import com.gitblit.wicket.CacheControl.LastModified;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.CommitHeaderPanel;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
|
| | |
|
| | | @CacheControl(LastModified.BOOT)
|
| | |
| | |
|
| | | final String blobPath = WicketUtils.getPath(params);
|
| | | final String baseObjectId = WicketUtils.getBaseObjectId(params);
|
| | | final DiffComparator diffComparator = WicketUtils.getDiffComparator(params);
|
| | |
|
| | | Repository r = getRepository();
|
| | | RevCommit commit = getCommit();
|
| | |
| | | RevCommit parent = commit.getParentCount() == 0 ? null : commit.getParent(0);
|
| | | ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName,
|
| | | parent.getName(), commit.getName(), imageExtensions);
|
| | | diff = DiffUtils.getDiff(r, commit, blobPath, DiffOutputType.HTML, handler).content;
|
| | | diff = DiffUtils.getDiff(r, commit, blobPath, diffComparator, DiffOutputType.HTML, handler).content;
|
| | | if (handler.getImgDiffCount() > 0) {
|
| | | addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs
|
| | | }
|
| | |
| | | RevCommit baseCommit = JGitUtils.getCommit(r, baseObjectId);
|
| | | ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName,
|
| | | baseCommit.getName(), commit.getName(), imageExtensions);
|
| | | diff = DiffUtils.getDiff(r, baseCommit, commit, blobPath, DiffOutputType.HTML, handler).content;
|
| | | diff = DiffUtils.getDiff(r, baseCommit, commit, blobPath, diffComparator, DiffOutputType.HTML, handler).content;
|
| | | if (handler.getImgDiffCount() > 0) {
|
| | | addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs
|
| | | }
|
| | |
| | | WicketUtils.newObjectParameter(repositoryName, objectId)));
|
| | | add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,
|
| | | WicketUtils.newObjectParameter(repositoryName, objectId)));
|
| | | add(new LinkPanel("whitespaceLink", null, getString(diffComparator.getOpposite().getTranslationKey()),
|
| | | BlobDiffPage.class, WicketUtils.newDiffParameter(repositoryName, objectId, diffComparator.getOpposite(), blobPath)));
|
| | |
|
| | | // diff page links
|
| | | add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
|
| | |
| | |
|
| | | <!-- commitdiff nav links -->
|
| | | <div class="page_nav2">
|
| | | <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>
|
| | | <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>
|
| | | </div>
|
| | |
|
| | | <!-- commit header -->
|
| | |
| | | import com.gitblit.models.SubmoduleModel; |
| | | import com.gitblit.servlet.RawServlet; |
| | | import com.gitblit.utils.DiffUtils; |
| | | import com.gitblit.utils.DiffUtils.DiffComparator; |
| | | import com.gitblit.utils.DiffUtils.DiffOutput; |
| | | import com.gitblit.utils.DiffUtils.DiffOutputType; |
| | | import com.gitblit.utils.JGitUtils; |
| | |
| | | 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 List<String> imageExtensions = app().settings().getStrings(Keys.web.imageExtensions); |
| | | final ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName, |
| | | parents.isEmpty() ? null : parents.get(0), commit.getName(), imageExtensions); |
| | | final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, DiffOutputType.HTML, handler); |
| | | |
| | | 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 |
| | | } |
| | |
| | | <select wicket:id="fromRef" class="span3" />
|
| | | <i class="icon-arrow-right"></i>
|
| | | <select wicket:id="toRef" class="span3" />
|
| | | <label style="padding:0px 5px;" class="checkbox"><input type="checkbox" wicket:id="ignoreWhitespaceCheckbox" /> <span wicket:id="ignoreWhitespaceLabel"></span></label>
|
| | | <button class="btn" type="submit"><wicket:message key="gb.compare"></wicket:message></button>
|
| | | </form>
|
| | | </div>
|
| | |
| | | <input wicket:id="fromId" type="text" class="span3" />
|
| | | <i class="icon-arrow-right"></i>
|
| | | <input wicket:id="toId" type="text" class="span3" />
|
| | | <label style="padding:0px 5px;" class="checkbox"><input type="checkbox" wicket:id="ignoreWhitespaceCheckbox" /> <span wicket:id="ignoreWhitespaceLabel"></span></label>
|
| | | <button class="btn" type="submit"><wicket:message key="gb.compare"></wicket:message></button>
|
| | | </form>
|
| | | </div>
|
| | |
| | | |
| | | import org.apache.wicket.PageParameters; |
| | | import org.apache.wicket.markup.html.basic.Label; |
| | | import org.apache.wicket.markup.html.form.CheckBox; |
| | | import org.apache.wicket.markup.html.form.DropDownChoice; |
| | | import org.apache.wicket.markup.html.form.TextField; |
| | | import org.apache.wicket.markup.html.link.BookmarkablePageLink; |
| | |
| | | import com.gitblit.models.SubmoduleModel; |
| | | import com.gitblit.servlet.RawServlet; |
| | | import com.gitblit.utils.DiffUtils; |
| | | import com.gitblit.utils.DiffUtils.DiffComparator; |
| | | import com.gitblit.utils.DiffUtils.DiffOutput; |
| | | import com.gitblit.utils.DiffUtils.DiffOutputType; |
| | | import com.gitblit.utils.JGitUtils; |
| | |
| | | |
| | | IModel<String> fromRefId = new Model<String>(""); |
| | | IModel<String> toRefId = new Model<String>(""); |
| | | |
| | | IModel<Boolean> ignoreWhitespace = Model.of(true); |
| | | |
| | | public ComparePage(PageParameters params) { |
| | | super(params); |
| | |
| | | final ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName, |
| | | fromCommit.getName(), toCommit.getName(), imageExtensions); |
| | | |
| | | final DiffOutput diff = DiffUtils.getDiff(r, fromCommit, toCommit, DiffOutputType.HTML, handler); |
| | | final DiffComparator diffComparator = WicketUtils.getDiffComparator(params); |
| | | final DiffOutput diff = DiffUtils.getDiff(r, fromCommit, toCommit, diffComparator, DiffOutputType.HTML, handler); |
| | | if (handler.getImgDiffCount() > 0) { |
| | | addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs |
| | | } |
| | |
| | | comparison.add(new Label("diffText", diff.content).setEscapeModelStrings(false)); |
| | | } |
| | | |
| | | // set the default DiffComparator |
| | | DiffComparator diffComparator = WicketUtils.getDiffComparator(params); |
| | | ignoreWhitespace.setObject(DiffComparator.IGNORE_WHITESPACE == diffComparator); |
| | | |
| | | // |
| | | // ref selection form |
| | | // |
| | |
| | | public void onSubmit() { |
| | | String from = ComparePage.this.fromRefId.getObject(); |
| | | String to = ComparePage.this.toRefId.getObject(); |
| | | boolean ignoreWS = ignoreWhitespace.getObject(); |
| | | |
| | | PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to); |
| | | if (ignoreWS) { |
| | | params.put("w", 1); |
| | | } |
| | | |
| | | String relativeUrl = urlFor(ComparePage.class, params).toString(); |
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl); |
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl)); |
| | |
| | | } |
| | | refsForm.add(new DropDownChoice<String>("fromRef", fromRefId, refs).setEnabled(refs.size() > 0)); |
| | | refsForm.add(new DropDownChoice<String>("toRef", toRefId, refs).setEnabled(refs.size() > 0)); |
| | | refsForm.add(new Label("ignoreWhitespaceLabel", getString(DiffComparator.IGNORE_WHITESPACE.getTranslationKey()))); |
| | | refsForm.add(new CheckBox("ignoreWhitespaceCheckbox", ignoreWhitespace)); |
| | | add(refsForm); |
| | | |
| | | // |
| | |
| | | public void onSubmit() { |
| | | String from = ComparePage.this.fromCommitId.getObject(); |
| | | String to = ComparePage.this.toCommitId.getObject(); |
| | | boolean ignoreWS = ignoreWhitespace.getObject(); |
| | | |
| | | PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to); |
| | | if (ignoreWS) { |
| | | params.put("w", 1); |
| | | } |
| | | String relativeUrl = urlFor(ComparePage.class, params).toString(); |
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl); |
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl)); |
| | |
| | | TextField<String> toIdField = new TextField<String>("toId", toCommitId); |
| | | WicketUtils.setInputPlaceholder(toIdField, getString("gb.to") + "..."); |
| | | idsForm.add(toIdField); |
| | | idsForm.add(new Label("ignoreWhitespaceLabel", getString(DiffComparator.IGNORE_WHITESPACE.getTranslationKey()))); |
| | | idsForm.add(new CheckBox("ignoreWhitespaceCheckbox", ignoreWhitespace)); |
| | | add(idsForm); |
| | | |
| | | r.close(); |
| | |
| | |
|
| | | import com.gitblit.models.AnnotatedLine;
|
| | | import com.gitblit.utils.DiffUtils;
|
| | | import com.gitblit.utils.DiffUtils.DiffComparator;
|
| | | import com.gitblit.utils.DiffUtils.DiffOutputType;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | |
|
| | |
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | RevCommit commit = JGitUtils.getCommit(repository,
|
| | | "1d0c2933a4ae69c362f76797d42d6bd182d05176");
|
| | | String diff = DiffUtils.getCommitDiff(repository, commit, DiffOutputType.PLAIN).content;
|
| | | String diff = DiffUtils.getCommitDiff(repository, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;
|
| | | repository.close();
|
| | | assertTrue(diff != null && diff.length() > 0);
|
| | | String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";
|
| | |
| | | "8baf6a833b5579384d9b9ceb8a16b5d0ea2ec4ca");
|
| | | RevCommit commit = JGitUtils.getCommit(repository,
|
| | | "1d0c2933a4ae69c362f76797d42d6bd182d05176");
|
| | | String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffOutputType.PLAIN).content;
|
| | | String diff = DiffUtils.getDiff(repository, baseCommit, commit, DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;
|
| | | repository.close();
|
| | | assertTrue(diff != null && diff.length() > 0);
|
| | | String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";
|
| | |
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | RevCommit commit = JGitUtils.getCommit(repository,
|
| | | "1d0c2933a4ae69c362f76797d42d6bd182d05176");
|
| | | String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffOutputType.PLAIN).content;
|
| | | String diff = DiffUtils.getDiff(repository, commit, "java.java", DiffComparator.SHOW_WHITESPACE, DiffOutputType.PLAIN).content;
|
| | | repository.close();
|
| | | assertTrue(diff != null && diff.length() > 0);
|
| | | String expected = "- system.out.println(\"Hello World\");\n+ System.out.println(\"Hello World\"";
|