diff options
author | Viktor Suprun <popsul1993@gmail.com> | 2022-02-08 17:15:04 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-08 14:15:04 +0800 |
commit | 4d939845d20d377e06bce5b02667ff21f69c3beb (patch) | |
tree | 3cfc0c54b5930a71c404961c26e7ae9e76060ffb /services/gitdiff | |
parent | 60f203385e6f27fae47f3cc8c5d71309f4fd88dc (diff) | |
download | gitea-4d939845d20d377e06bce5b02667ff21f69c3beb.tar.gz gitea-4d939845d20d377e06bce5b02667ff21f69c3beb.zip |
Added auto-save whitespace behavior if it changed manually (#15566)
Diffstat (limited to 'services/gitdiff')
-rw-r--r-- | services/gitdiff/gitdiff.go | 10 |
1 files changed, 7 insertions, 3 deletions
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 "" } |