Code

Teach --wrap to only indent without wrapping
authorJunio C Hamano <gitster@pobox.com>
Mon, 19 Oct 2009 06:40:35 +0000 (23:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Oct 2009 06:20:16 +0000 (23:20 -0700)
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>
utf8.c

diff --git a/utf8.c b/utf8.c
index da996695ccf06315f10f9c837d62784f1c34ed05..5c18f0c28107c91d9b2ec124ea2896d20945aa58 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -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;