提交 74474a94 编写于 作者: J Junio C Hamano

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
...@@ -306,9 +306,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) ...@@ -306,9 +306,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
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' ' ...@@ -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
} }
......
...@@ -323,7 +323,7 @@ static size_t display_mode_esc_sequence_len(const char *s) ...@@ -323,7 +323,7 @@ static size_t display_mode_esc_sequence_len(const char *s)
* If indent is negative, assume that already -indent columns have been * If indent is negative, assume that already -indent columns have been
* consumed (and no extra indent is necessary for the first line). * consumed (and no extra indent is necessary for the first line).
*/ */
int strbuf_add_wrapped_text(struct strbuf *buf, void strbuf_add_wrapped_text(struct strbuf *buf,
const char *text, int indent1, int indent2, int width) const char *text, int indent1, int indent2, int width)
{ {
int indent, w, assume_utf8 = 1; int indent, w, assume_utf8 = 1;
...@@ -332,7 +332,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf, ...@@ -332,7 +332,7 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
if (width <= 0) { if (width <= 0) {
strbuf_add_indented_text(buf, text, indent1, indent2); strbuf_add_indented_text(buf, text, indent1, indent2);
return 1; return;
} }
retry: retry:
...@@ -356,14 +356,14 @@ int strbuf_add_wrapped_text(struct strbuf *buf, ...@@ -356,14 +356,14 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
if (w <= width || !space) { if (w <= width || !space) {
const char *start = bol; const char *start = bol;
if (!c && text == start) if (!c && text == start)
return w; return;
if (space) if (space)
start = space; start = space;
else else
strbuf_addchars(buf, ' ', indent); strbuf_addchars(buf, ' ', indent);
strbuf_add(buf, start, text - start); strbuf_add(buf, start, text - start);
if (!c) if (!c)
return w; return;
space = text; space = text;
if (c == '\t') if (c == '\t')
w |= 0x07; w |= 0x07;
...@@ -405,13 +405,12 @@ int strbuf_add_wrapped_text(struct strbuf *buf, ...@@ -405,13 +405,12 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
} }
} }
int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len, void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
int indent, int indent2, int width) int indent, int indent2, int width)
{ {
char *tmp = xstrndup(data, len); char *tmp = xstrndup(data, len);
int r = strbuf_add_wrapped_text(buf, tmp, indent, indent2, width); strbuf_add_wrapped_text(buf, tmp, indent, indent2, width);
free(tmp); free(tmp);
return r;
} }
int is_encoding_utf8(const char *name) int is_encoding_utf8(const char *name)
......
...@@ -9,9 +9,9 @@ int is_utf8(const char *text); ...@@ -9,9 +9,9 @@ int is_utf8(const char *text);
int is_encoding_utf8(const char *name); int is_encoding_utf8(const char *name);
int same_encoding(const char *, const char *); int same_encoding(const char *, const char *);
int strbuf_add_wrapped_text(struct strbuf *buf, void strbuf_add_wrapped_text(struct strbuf *buf,
const char *text, int indent, int indent2, int width); const char *text, int indent, int indent2, int width);
int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len, void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
int indent, int indent2, int width); int indent, int indent2, int width);
#ifndef NO_ICONV #ifndef NO_ICONV
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册