git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] shortlog: Fix wrapping lines of wraplen (was broken since recent off-by-one fix)

From
Steffen Prohaska <prohaska@zib.de>
Date
Dec 11, 2012, 05:59 UTC
Message-ID
<1355205562-23459-2-git-send-email-prohaska@zib.de>
In-Reply-To
<1355205562-23459-1-git-send-email-prohaska@zib.de>

A recent commit [1] fixed a off-by-one wrapping error. As a side-effect, the conditional in add_wrapped_shortlog_msg() whether to append a newline needs to be removed. add_wrapped_shortlog_msg() should always append a newline, which was the case before the off-by-one fix, because strbuf_add_wrapped_text() never returned a value of wraplen.

[1] 14e1a4e1ff70aff36db3f5d2a8b806efd0134d50 utf8: fix off-by-one
    wrapping of text
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 builtin/shortlog.c  |  5 ++---
 t/t4201-shortlog.sh | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index b316cf3..8360514 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -306,9 +306,8 @@ parse_done:
 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_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
+	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):
+      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() {
 	printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
 }
-- 
1.8.1.rc1.2.gfb98a3a
Previous: Steffen ProhaskaNext: Jan H. Schönherr
Message 4 of 6 in “shortlog: Fix wrapping lines of wraplen (was broken since recent off-by-one fix)”
  1. shortlog: Fix wrapping lines of wraplen (was broken since recent off-by-one fix)Steffen Prohaska, Dec 8, 2012
  2. Junio C HamanoDec 9, 2012
  3. 0/2 Re: [PATCH] shortlog: Fix wrapping lines of wraplenSteffen Prohaska, Dec 11, 2012
  4. 1/2 shortlog: Fix wrapping lines of wraplen (was broken since recent off-by-one fix)Steffen Prohaska, Dec 11, 2012
  5. Jan H. SchönherrDec 11, 2012
  6. 2/2 strbuf_add_wrapped*(): Remove unused return valueSteffen Prohaska, Dec 11, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.