Steffen Prohaska proha...@zib.de writes:
A recent commit [1] fixed a off-by-one wrapping error. As
a side-effect, add_wrapped_shortlog_msg() needs to be changed to always
append a newline.
Could you clarify As a side effect a bit more? Do you mean
something like this?
Earlier strbuf_add_wrapped_text() ended its output with a
newline only when the end of the text exactly fitted in wrap
length, due to the off-by-one error fixed with 14e1a4e (utf8:
fix off-by-one wrapping of text, 2012-10-18). There was a hack
in add_wrapped_shortlog_msg() function to compensate for this
bug.
With the bug fixed, the function never ends its output with a
newline, and the caller needs to unconditionally add one.
[1] 14e1a4e1ff70aff36db3f5d2a8b806efd0134d50 utf8: fix off-by-one
wrapping of text
Signed-off-by: Steffen Prohaska proha...@zib.de
---
builtin/shortlog.c | 3 +--
t/t4201-shortlog.sh | 24
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index b316cf3..db5b57d 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -307,8 +307,7 @@ static void add_wrapped_shortlog_msg(struct strbuf *sb,
const char *s,
const struct shortlog *log)
{
int col = 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)
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 6872ba1..02ac978 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -120,6 +120,30 @@ test_expect_success 'shortlog from non-git directory' '
test_cmp expect out
'
+test_expect_success 'shortlog should add newline when input line matches
wraplen' '
+ cat expect \EOF
+A U Thor (2):
+ bb: bbb bbb bb bbb b bb
+ aa: aa aa aa aa aaa
+
+EOF
+ git shortlog -w out \EOF
+commit 0001
+Author: A U Thor aut...@example.com
+Date: Thu Apr 7 15:14:13 2005 -0700
+
+aa: aa aa aa aa aaa
+
+commit 0002
+Author: A U Thor aut...@example.com
+Date: Thu Apr 7 15:14:13 2005 -0700
+
+bb: bbb bbb bb bbb b bb
+
+EOF
+ test_cmp expect out
+'
+
iconvfromutf8toiso88591() {
printf %s $* | iconv -f UTF-8 -t ISO8859-1
}
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html