Skip to content

Commit 74474a9

Browse files
committed
Merge branch 'sp/shortlog-missing-lf' into maint
* sp/shortlog-missing-lf: strbuf_add_wrapped*(): Remove unused return value shortlog: fix wrapping lines of wraplen
2 parents 2601298 + e0db176 commit 74474a9

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

builtin/shortlog.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
306306
static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
307307
const struct shortlog *log)
308308
{
309-
int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
310-
if (col != log->wrap)
311-
strbuf_addch(sb, '\n');
309+
strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
310+
strbuf_addch(sb, '\n');
312311
}
313312

314313
void shortlog_output(struct shortlog *log)

t/t4201-shortlog.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,30 @@ test_expect_success 'shortlog from non-git directory' '
120120
test_cmp expect out
121121
'
122122

123+
test_expect_success 'shortlog should add newline when input line matches wraplen' '
124+
cat >expect <<\EOF &&
125+
A U Thor (2):
126+
bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb
127+
aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa
128+
129+
EOF
130+
git shortlog -w >out <<\EOF &&
131+
commit 0000000000000000000000000000000000000001
132+
Author: A U Thor <[email protected]>
133+
Date: Thu Apr 7 15:14:13 2005 -0700
134+
135+
aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa
136+
137+
commit 0000000000000000000000000000000000000002
138+
Author: A U Thor <[email protected]>
139+
Date: Thu Apr 7 15:14:13 2005 -0700
140+
141+
bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb
142+
143+
EOF
144+
test_cmp expect out
145+
'
146+
123147
iconvfromutf8toiso88591() {
124148
printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
125149
}

utf8.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static size_t display_mode_esc_sequence_len(const char *s)
323323
* If indent is negative, assume that already -indent columns have been
324324
* consumed (and no extra indent is necessary for the first line).
325325
*/
326-
int strbuf_add_wrapped_text(struct strbuf *buf,
326+
void strbuf_add_wrapped_text(struct strbuf *buf,
327327
const char *text, int indent1, int indent2, int width)
328328
{
329329
int indent, w, assume_utf8 = 1;
@@ -332,7 +332,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
332332

333333
if (width <= 0) {
334334
strbuf_add_indented_text(buf, text, indent1, indent2);
335-
return 1;
335+
return;
336336
}
337337

338338
retry:
@@ -356,14 +356,14 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
356356
if (w <= width || !space) {
357357
const char *start = bol;
358358
if (!c && text == start)
359-
return w;
359+
return;
360360
if (space)
361361
start = space;
362362
else
363363
strbuf_addchars(buf, ' ', indent);
364364
strbuf_add(buf, start, text - start);
365365
if (!c)
366-
return w;
366+
return;
367367
space = text;
368368
if (c == '\t')
369369
w |= 0x07;
@@ -405,13 +405,12 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
405405
}
406406
}
407407

408-
int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
408+
void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
409409
int indent, int indent2, int width)
410410
{
411411
char *tmp = xstrndup(data, len);
412-
int r = strbuf_add_wrapped_text(buf, tmp, indent, indent2, width);
412+
strbuf_add_wrapped_text(buf, tmp, indent, indent2, width);
413413
free(tmp);
414-
return r;
415414
}
416415

417416
int is_encoding_utf8(const char *name)

utf8.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ int is_utf8(const char *text);
99
int is_encoding_utf8(const char *name);
1010
int same_encoding(const char *, const char *);
1111

12-
int strbuf_add_wrapped_text(struct strbuf *buf,
12+
void strbuf_add_wrapped_text(struct strbuf *buf,
1313
const char *text, int indent, int indent2, int width);
14-
int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
14+
void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
1515
int indent, int indent2, int width);
1616

1717
#ifndef NO_ICONV

0 commit comments

Comments
 (0)