Skip to content

Commit

Permalink
Teach --wrap to only indent without wrapping
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Oct 23, 2009
1 parent a94410c commit 00d3947
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,19 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
int w = indent, assume_utf8 = is_utf8(text);
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) {
w = -indent;
space = text;
Expand Down

0 comments on commit 00d3947

Please sign in to comment.