diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt index 9846329cbf..a5dffd1df0 100644 --- a/Documentation/rest-api-changes.txt +++ b/Documentation/rest-api-changes.txt @@ -3670,8 +3670,9 @@ If the `weblinks-only` parameter is specified, only the diff web links are retur } ---- -The `ignore-whitespace` parameter can be specified to control how whitespace differences are -reported in the result. Valid values are `NONE`, `TRAILING`, `CHANGED` or `ALL`. +The `whitespace` parameter can be specified to control how whitespace +differences are reported in the result. Valid values are `IGNORE_NONE`, +`IGNORE_TRAILING`, `IGNORE_LEADING_AND_TRAILING` or `IGNORE_ALL`. The `context` parameter can be specified to control the number of lines of surrounding context in the diff. Valid values are `ALL` or number of lines. diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffApi.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffApi.java index 6d795d30da..df51c75343 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffApi.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffApi.java @@ -19,6 +19,7 @@ import com.google.gerrit.client.info.FileInfo; import com.google.gerrit.client.rpc.NativeMap; import com.google.gerrit.client.rpc.RestApi; import com.google.gerrit.extensions.client.DiffPreferencesInfo; +import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -70,22 +71,8 @@ public class DiffApi { } public DiffApi ignoreWhitespace(DiffPreferencesInfo.Whitespace w) { - switch (w) { - default: - case IGNORE_NONE: - return ignoreWhitespace(IgnoreWhitespace.NONE); - case IGNORE_TRAILING: - return ignoreWhitespace(IgnoreWhitespace.TRAILING); - case IGNORE_LEADING_AND_TRAILING: - return ignoreWhitespace(IgnoreWhitespace.CHANGED); - case IGNORE_ALL: - return ignoreWhitespace(IgnoreWhitespace.ALL); - } - } - - public DiffApi ignoreWhitespace(IgnoreWhitespace w) { - if (w != null && w != IgnoreWhitespace.NONE) { - call.addParameter("ignore-whitespace", w); + if (w != null && w != Whitespace.IGNORE_ALL) { + call.addParameter("whitespace", w); } return this; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/GetDiff.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/GetDiff.java index 1546e345d3..1ab4e85487 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/GetDiff.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/GetDiff.java @@ -25,6 +25,7 @@ import com.google.common.collect.Maps; import com.google.gerrit.common.data.PatchScript; import com.google.gerrit.common.data.PatchScript.DisplayMethod; import com.google.gerrit.extensions.client.DiffPreferencesInfo; +import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.extensions.common.ChangeType; import com.google.gerrit.extensions.common.DiffInfo; import com.google.gerrit.extensions.common.DiffInfo.ContentEntry; @@ -89,8 +90,12 @@ public class GetDiff implements RestReadView { @Option(name = "--base", metaVar = "REVISION") String base; + @Deprecated @Option(name = "--ignore-whitespace") - IgnoreWhitespace ignoreWhitespace = IgnoreWhitespace.NONE; + IgnoreWhitespace ignoreWhitespace; + + @Option(name = "--whitespace") + Whitespace whitespace; @Option(name = "--context", handler = ContextOptionHandler.class) int context = DiffPreferencesInfo.DEFAULT_CONTEXT; @@ -123,7 +128,13 @@ public class GetDiff implements RestReadView { basePatchSet = baseResource.getPatchSet(); } DiffPreferencesInfo prefs = new DiffPreferencesInfo(); - prefs.ignoreWhitespace = ignoreWhitespace.whitespace; + if (whitespace != null) { + prefs.ignoreWhitespace = whitespace; + } else if (ignoreWhitespace != null) { + prefs.ignoreWhitespace = ignoreWhitespace.whitespace; + } else { + prefs.ignoreWhitespace = Whitespace.IGNORE_ALL; + } prefs.context = context; prefs.intralineDifference = intraline; @@ -368,6 +379,7 @@ public class GetDiff implements RestReadView { } } + @Deprecated enum IgnoreWhitespace { NONE(DiffPreferencesInfo.Whitespace.IGNORE_NONE), TRAILING(DiffPreferencesInfo.Whitespace.IGNORE_TRAILING),