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 <gitster@pobox.com>
This commit is contained in:
parent
a94410c813
commit
00d3947366
13
utf8.c
13
utf8.c
@ -310,6 +310,19 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
|
|||||||
int w = indent, assume_utf8 = is_utf8(text);
|
int w = indent, assume_utf8 = is_utf8(text);
|
||||||
const char *bol = text, *space = NULL;
|
const char *bol = text, *space = NULL;
|
||||||
|
|
||||||
|
if (width <= 0) {
|
||||||
|
/* just indent */
|
||||||
|
while (*text) {
|
||||||
|
const char *eol = strchrnul(text, '\n');
|
||||||
|
if (*eol == '\n')
|
||||||
|
eol++;
|
||||||
|
print_spaces(buf, indent);
|
||||||
|
strbuf_write(buf, text, eol-text);
|
||||||
|
text = eol;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (indent < 0) {
|
if (indent < 0) {
|
||||||
w = -indent;
|
w = -indent;
|
||||||
space = text;
|
space = text;
|
||||||
|
Loading…
Reference in New Issue
Block a user