From 4d939845d20d377e06bce5b02667ff21f69c3beb Mon Sep 17 00:00:00 2001 From: Viktor Suprun Date: Tue, 8 Feb 2022 17:15:04 +1100 Subject: Added auto-save whitespace behavior if it changed manually (#15566) --- services/gitdiff/gitdiff.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'services/gitdiff') diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 0fcb361619..017341d63f 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -1532,13 +1532,17 @@ func CommentMustAsDiff(c *models.Comment) *Diff { } // GetWhitespaceFlag returns git diff flag for treating whitespaces -func GetWhitespaceFlag(whiteSpaceBehavior string) string { +func GetWhitespaceFlag(whitespaceBehavior string) string { whitespaceFlags := map[string]string{ "ignore-all": "-w", "ignore-change": "-b", "ignore-eol": "--ignore-space-at-eol", - "": "", + "show-all": "", } - return whitespaceFlags[whiteSpaceBehavior] + if flag, ok := whitespaceFlags[whitespaceBehavior]; ok { + return flag + } + log.Warn("unknown whitespace behavior: %q, default to 'show-all'", whitespaceBehavior) + return "" } -- cgit v1.2.3