Skip to content

Commit 46cdcc6

Browse files
committed
Merge branch 'rs/maint-shortlog-foldline' into maint
* rs/maint-shortlog-foldline: shortlog: handle multi-line subjects like log --pretty=oneline et. al. do
2 parents 67b175b + cec0871 commit 46cdcc6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

builtin-shortlog.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ static int compare_by_number(const void *a1, const void *a2)
2929
return -1;
3030
}
3131

32+
const char *format_subject(struct strbuf *sb, const char *msg,
33+
const char *line_separator);
34+
3235
static void insert_one_record(struct shortlog *log,
3336
const char *author,
3437
const char *oneline)
@@ -41,6 +44,7 @@ static void insert_one_record(struct shortlog *log,
4144
size_t len;
4245
const char *eol;
4346
const char *boemail, *eoemail;
47+
struct strbuf subject = STRBUF_INIT;
4448

4549
boemail = strchr(author, '<');
4650
if (!boemail)
@@ -89,9 +93,8 @@ static void insert_one_record(struct shortlog *log,
8993
while (*oneline && isspace(*oneline) && *oneline != '\n')
9094
oneline++;
9195
len = eol - oneline;
92-
while (len && isspace(oneline[len-1]))
93-
len--;
94-
buffer = xmemdupz(oneline, len);
96+
format_subject(&subject, oneline, " ");
97+
buffer = strbuf_detach(&subject, NULL);
9598

9699
if (dot3) {
97100
int dot3len = strlen(dot3);

pretty.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ static void parse_commit_header(struct format_commit_context *context)
486486
context->commit_header_parsed = 1;
487487
}
488488

489-
static const char *format_subject(struct strbuf *sb, const char *msg,
490-
const char *line_separator)
489+
const char *format_subject(struct strbuf *sb, const char *msg,
490+
const char *line_separator)
491491
{
492492
int first = 1;
493493

0 commit comments

Comments
 (0)