Skip to content

Commit 00d3947

Browse files
committed
Teach --wrap to only indent without wrapping
When a zero or negative width is given to "shortlog -w<width>,<in1>,<in2>" and --format=%[wrap(w,in1,in2)...%], just indent the text by in1 without wrapping. Signed-off-by: Junio C Hamano <[email protected]>
1 parent a94410c commit 00d3947

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

utf8.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
310310
int w = indent, assume_utf8 = is_utf8(text);
311311
const char *bol = text, *space = NULL;
312312

313+
if (width <= 0) {
314+
/* just indent */
315+
while (*text) {
316+
const char *eol = strchrnul(text, '\n');
317+
if (*eol == '\n')
318+
eol++;
319+
print_spaces(buf, indent);
320+
strbuf_write(buf, text, eol-text);
321+
text = eol;
322+
}
323+
return 1;
324+
}
325+
313326
if (indent < 0) {
314327
w = -indent;
315328
space = text;

0 commit comments

Comments
 (0)