shortlog: fix wrapping lines of wraplen
A recent commit [1] fixed a off-by-one wrapping error. As a
side-effect, the conditional in add_wrapped_shortlog_msg() to decide
whether to append a newline needs to be removed. The function
should always append a newline, which was the case before the
off-by-one fix, because strbuf_add_wrapped_text() never returns a
value of wraplen; when it returns wraplen, the string does not end
with a newline, so this caller needs to add one anyway.
[1] 14e1a4e1ff
utf8: fix off-by-one
wrapping of text
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
14e1a4e1ff
commit
5b59708268
@ -306,9 +306,8 @@ parse_done:
|
|||||||
static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
|
static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
|
||||||
const struct shortlog *log)
|
const struct shortlog *log)
|
||||||
{
|
{
|
||||||
int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
|
strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
|
||||||
if (col != log->wrap)
|
strbuf_addch(sb, '\n');
|
||||||
strbuf_addch(sb, '\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shortlog_output(struct shortlog *log)
|
void shortlog_output(struct shortlog *log)
|
||||||
|
@ -120,6 +120,30 @@ test_expect_success 'shortlog from non-git directory' '
|
|||||||
test_cmp expect out
|
test_cmp expect out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'shortlog should add newline when input line matches wraplen' '
|
||||||
|
cat >expect <<\EOF &&
|
||||||
|
A U Thor (2):
|
||||||
|
bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa
|
||||||
|
|
||||||
|
EOF
|
||||||
|
git shortlog -w >out <<\EOF &&
|
||||||
|
commit 0000000000000000000000000000000000000001
|
||||||
|
Author: A U Thor <author@example.com>
|
||||||
|
Date: Thu Apr 7 15:14:13 2005 -0700
|
||||||
|
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa
|
||||||
|
|
||||||
|
commit 0000000000000000000000000000000000000002
|
||||||
|
Author: A U Thor <author@example.com>
|
||||||
|
Date: Thu Apr 7 15:14:13 2005 -0700
|
||||||
|
|
||||||
|
bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb
|
||||||
|
|
||||||
|
EOF
|
||||||
|
test_cmp expect out
|
||||||
|
'
|
||||||
|
|
||||||
iconvfromutf8toiso88591() {
|
iconvfromutf8toiso88591() {
|
||||||
printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
|
printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user