If tab-in-indent is set, --whitespace=fix will ensure that any stray tabs in the initial indent are expanded to the correct number of space characters. Signed-off-by: Chris Webb <chris@xxxxxxxxxxxx> --- ws.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ws.c b/ws.c index 897ff56..e581535 100644 --- a/ws.c +++ b/ws.c @@ -313,8 +313,9 @@ void ws_fix_copy(struct strbuf *dst, const char *src, int len, unsigned ws_rule, char ch = src[i]; if (ch == '\t') { last_tab_in_indent = i; - if ((ws_rule & WS_SPACE_BEFORE_TAB) && - 0 <= last_space_in_indent) + if ((ws_rule & WS_TAB_IN_INDENT) || + ((ws_rule & WS_SPACE_BEFORE_TAB) && + 0 <= last_space_in_indent)) need_fix_leading_space = 1; } else if (ch == ' ') { last_space_in_indent = i; @@ -325,7 +326,21 @@ void ws_fix_copy(struct strbuf *dst, const char *src, int len, unsigned ws_rule, break; } - if (need_fix_leading_space) { + if ((ws_rule & WS_TAB_IN_INDENT) && last_tab_in_indent >= 0) { + /* Expand tabs into spaces */ + int last = last_tab_in_indent + 1; + for (i = 0; i < last; i++) { + if (src[i] == '\t') + do { + strbuf_addch(dst, ' '); + } while (dst->len % 8); + else + strbuf_addch(dst, src[i]); + } + len -= last; + src += last; + fixed = 1; + } else if (need_fix_leading_space) { /* Process indent ourselves */ int consecutive_spaces = 0; int last = last_tab_in_indent + 1; -- 1.7.0.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html