MCPcopy Index your code
hub / github.com/git/git / whitespace_error_string

Function whitespace_error_string

ws.c:114–149  ·  view source on GitHub ↗

The returned string should be freed by the caller. */

Source from the content-addressed store, hash-verified

112
113/* The returned string should be freed by the caller. */
114char *whitespace_error_string(unsigned ws)
115{
116 struct strbuf err = STRBUF_INIT;
117 if ((ws & WS_TRAILING_SPACE) == WS_TRAILING_SPACE)
118 strbuf_addstr(&err, "trailing whitespace");
119 else {
120 if (ws & WS_BLANK_AT_EOL)
121 strbuf_addstr(&err, "trailing whitespace");
122 if (ws & WS_BLANK_AT_EOF) {
123 if (err.len)
124 strbuf_addstr(&err, ", ");
125 strbuf_addstr(&err, "new blank line at EOF");
126 }
127 }
128 if (ws & WS_SPACE_BEFORE_TAB) {
129 if (err.len)
130 strbuf_addstr(&err, ", ");
131 strbuf_addstr(&err, "space before tab in indent");
132 }
133 if (ws & WS_INDENT_WITH_NON_TAB) {
134 if (err.len)
135 strbuf_addstr(&err, ", ");
136 strbuf_addstr(&err, "indent with spaces");
137 }
138 if (ws & WS_TAB_IN_INDENT) {
139 if (err.len)
140 strbuf_addstr(&err, ", ");
141 strbuf_addstr(&err, "tab in indent");
142 }
143 if (ws & WS_INCOMPLETE_LINE) {
144 if (err.len)
145 strbuf_addstr(&err, ", ");
146 strbuf_addstr(&err, "no newline at the end of file");
147 }
148 return strbuf_detach(&err, NULL);
149}
150
151/* If stream is non-NULL, emits the line after checking. */
152static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,

Callers 3

record_ws_errorFunction · 0.85
checkdiff_consumeFunction · 0.85
builtin_checkdiffFunction · 0.85

Calls 2

strbuf_addstrFunction · 0.85
strbuf_detachFunction · 0.85

Tested by

no test coverage detected