blob: 65cd41392c1c5e256313b10812a39bf4b848ce1b [file] [log] [blame]
Johannes Schindelinb8ec5922006-10-22 13:23:31 +02001#include "builtin.h"
2#include "cache.h"
Brandon Williamsb2141fc2017-06-14 11:07:36 -07003#include "config.h"
Johannes Schindelinb8ec5922006-10-22 13:23:31 +02004#include "commit.h"
5#include "diff.h"
Johannes Schindelinc455c872008-07-21 19:03:49 +01006#include "string-list.h"
Johannes Schindelinb8ec5922006-10-22 13:23:31 +02007#include "revision.h"
Johannes Schindelin3714e7c2006-12-22 22:15:59 +01008#include "utf8.h"
Junio C Hamano7c1c6782007-04-27 00:41:15 -07009#include "mailmap.h"
Daniel Barkalow552bcac2008-02-25 18:24:14 -050010#include "shortlog.h"
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +020011#include "parse-options.h"
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020012
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +020013static char const * const shortlog_usage[] = {
Martin Ågrencd56d4e2018-03-10 12:52:11 +010014 N_("git shortlog [<options>] [<revision-range>] [[--] <path>...]"),
15 N_("git log --pretty=short | git shortlog [<options>]"),
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +020016 NULL
17};
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020018
Jeff King9b21a342016-01-18 15:02:59 -050019/*
20 * The util field of our string_list_items will contain one of two things:
21 *
22 * - if --summary is not in use, it will point to a string list of the
23 * oneline subjects assigned to this author
24 *
25 * - if --summary is in use, we don't need that list; we only need to know
26 * its size. So we abuse the pointer slot to store our integer counter.
27 *
28 * This macro accesses the latter.
29 */
30#define UTIL_TO_INT(x) ((intptr_t)(x)->util)
31
32static int compare_by_counter(const void *a1, const void *a2)
33{
34 const struct string_list_item *i1 = a1, *i2 = a2;
35 return UTIL_TO_INT(i2) - UTIL_TO_INT(i1);
36}
37
38static int compare_by_list(const void *a1, const void *a2)
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020039{
Johannes Schindelinc455c872008-07-21 19:03:49 +010040 const struct string_list_item *i1 = a1, *i2 = a2;
41 const struct string_list *l1 = i1->util, *l2 = i2->util;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020042
43 if (l1->nr < l2->nr)
Johannes Schindelin6d6ab612006-11-21 21:12:06 +010044 return 1;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020045 else if (l1->nr == l2->nr)
46 return 0;
47 else
Johannes Schindelin6d6ab612006-11-21 21:12:06 +010048 return -1;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020049}
50
Daniel Barkalow552bcac2008-02-25 18:24:14 -050051static void insert_one_record(struct shortlog *log,
Junio C Hamano1e931cb2007-12-07 17:07:41 -080052 const char *author,
53 const char *oneline)
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020054{
Johannes Schindelinc455c872008-07-21 19:03:49 +010055 struct string_list_item *item;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020056
Jeff King1ab03a52017-09-08 05:21:27 -040057 item = string_list_insert(&log->list, author);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020058
Jeff Kinged7eba92016-01-18 15:02:56 -050059 if (log->summary)
Jeff King9b21a342016-01-18 15:02:59 -050060 item->util = (void *)(UTIL_TO_INT(item) + 1);
Jeff Kinged7eba92016-01-18 15:02:56 -050061 else {
62 const char *dot3 = log->common_repo_prefix;
63 char *buffer, *p;
64 struct strbuf subject = STRBUF_INIT;
65 const char *eol;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020066
Jeff Kinged7eba92016-01-18 15:02:56 -050067 /* Skip any leading whitespace, including any blank lines. */
68 while (*oneline && isspace(*oneline))
69 oneline++;
70 eol = strchr(oneline, '\n');
71 if (!eol)
72 eol = oneline + strlen(oneline);
73 if (starts_with(oneline, "[PATCH")) {
74 char *eob = strchr(oneline, ']');
75 if (eob && (!eol || eob < eol))
76 oneline = eob + 1;
77 }
78 while (*oneline && isspace(*oneline) && *oneline != '\n')
79 oneline++;
80 format_subject(&subject, oneline, " ");
81 buffer = strbuf_detach(&subject, NULL);
82
83 if (dot3) {
84 int dot3len = strlen(dot3);
85 if (dot3len > 5) {
86 while ((p = strstr(buffer, dot3)) != NULL) {
87 int taillen = strlen(p) - dot3len;
88 memcpy(p, "/.../", 5);
89 memmove(p + 5, p + dot3len, taillen + 1);
90 }
Junio C Hamanoc95044d2006-11-25 00:01:27 -080091 }
92 }
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020093
Jeff King9b21a342016-01-18 15:02:59 -050094 if (item->util == NULL)
95 item->util = xcalloc(1, sizeof(struct string_list));
Jeff Kinged7eba92016-01-18 15:02:56 -050096 string_list_append(item->util, buffer);
97 }
Johannes Schindelinb8ec5922006-10-22 13:23:31 +020098}
99
Jeff King1ab03a52017-09-08 05:21:27 -0400100static int parse_stdin_author(struct shortlog *log,
101 struct strbuf *out, const char *in)
102{
103 const char *mailbuf, *namebuf;
104 size_t namelen, maillen;
105 struct ident_split ident;
106
107 if (split_ident_line(&ident, in, strlen(in)))
108 return -1;
109
110 namebuf = ident.name_begin;
111 mailbuf = ident.mail_begin;
112 namelen = ident.name_end - ident.name_begin;
113 maillen = ident.mail_end - ident.mail_begin;
114
115 map_user(&log->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
116 strbuf_add(out, namebuf, namelen);
117 if (log->email)
118 strbuf_addf(out, " <%.*s>", (int)maillen, mailbuf);
119
120 return 0;
121}
122
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500123static void read_from_stdin(struct shortlog *log)
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200124{
Jeff King50250492016-01-18 15:02:44 -0500125 struct strbuf author = STRBUF_INIT;
Jeff King1ab03a52017-09-08 05:21:27 -0400126 struct strbuf mapped_author = STRBUF_INIT;
Jeff King50250492016-01-18 15:02:44 -0500127 struct strbuf oneline = STRBUF_INIT;
Linus Torvaldsfbfda152016-10-11 11:45:58 -0700128 static const char *author_match[2] = { "Author: ", "author " };
129 static const char *committer_match[2] = { "Commit: ", "committer " };
130 const char **match;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200131
Linus Torvaldsfbfda152016-10-11 11:45:58 -0700132 match = log->committer ? committer_match : author_match;
Junio C Hamanoa1c54052016-01-28 16:10:14 -0800133 while (strbuf_getline_lf(&author, stdin) != EOF) {
Jeff King5c3894c2016-01-18 15:02:40 -0500134 const char *v;
Linus Torvaldsfbfda152016-10-11 11:45:58 -0700135 if (!skip_prefix(author.buf, match[0], &v) &&
136 !skip_prefix(author.buf, match[1], &v))
Junio C Hamano1e931cb2007-12-07 17:07:41 -0800137 continue;
Junio C Hamanoa1c54052016-01-28 16:10:14 -0800138 while (strbuf_getline_lf(&oneline, stdin) != EOF &&
Jeff King50250492016-01-18 15:02:44 -0500139 oneline.len)
Junio C Hamano1e931cb2007-12-07 17:07:41 -0800140 ; /* discard headers */
Junio C Hamanoa1c54052016-01-28 16:10:14 -0800141 while (strbuf_getline_lf(&oneline, stdin) != EOF &&
Jeff King50250492016-01-18 15:02:44 -0500142 !oneline.len)
Junio C Hamano1e931cb2007-12-07 17:07:41 -0800143 ; /* discard blanks */
Jeff King1ab03a52017-09-08 05:21:27 -0400144
145 strbuf_reset(&mapped_author);
146 if (parse_stdin_author(log, &mapped_author, v) < 0)
147 continue;
148
149 insert_one_record(log, mapped_author.buf, oneline.buf);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200150 }
Jeff King50250492016-01-18 15:02:44 -0500151 strbuf_release(&author);
Jeff King1ab03a52017-09-08 05:21:27 -0400152 strbuf_release(&mapped_author);
Jeff King50250492016-01-18 15:02:44 -0500153 strbuf_release(&oneline);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200154}
155
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500156void shortlog_add_commit(struct shortlog *log, struct commit *commit)
157{
Jeff King2db6b832016-01-18 15:02:48 -0500158 struct strbuf author = STRBUF_INIT;
159 struct strbuf oneline = STRBUF_INIT;
160 struct pretty_print_context ctx = {0};
Linus Torvaldsfbfda152016-10-11 11:45:58 -0700161 const char *fmt;
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500162
Jeff King2db6b832016-01-18 15:02:48 -0500163 ctx.fmt = CMIT_FMT_USERFORMAT;
164 ctx.abbrev = log->abbrev;
René Scharfe6d167fd2017-03-01 12:37:07 +0100165 ctx.print_email_subject = 1;
Jeff King2db6b832016-01-18 15:02:48 -0500166 ctx.date_mode.type = DATE_NORMAL;
167 ctx.output_encoding = get_log_output_encoding();
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500168
Jeff King1ab03a52017-09-08 05:21:27 -0400169 fmt = log->committer ?
170 (log->email ? "%cN <%cE>" : "%cN") :
171 (log->email ? "%aN <%aE>" : "%aN");
Linus Torvaldsfbfda152016-10-11 11:45:58 -0700172
173 format_commit_message(commit, fmt, &author, &ctx);
Jeff King4e1d1a22016-01-18 15:02:52 -0500174 if (!log->summary) {
175 if (log->user_format)
176 pretty_print_commit(&ctx, commit, &oneline);
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500177 else
Jeff King4e1d1a22016-01-18 15:02:52 -0500178 format_commit_message(commit, "%s", &oneline, &ctx);
179 }
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500180
Jeff King2db6b832016-01-18 15:02:48 -0500181 insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
182
Jeff King2db6b832016-01-18 15:02:48 -0500183 strbuf_release(&author);
184 strbuf_release(&oneline);
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500185}
186
187static void get_from_rev(struct rev_info *rev, struct shortlog *log)
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200188{
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200189 struct commit *commit;
190
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500191 if (prepare_revision_walk(rev))
Ævar Arnfjörð Bjarmasonab8b53b2011-02-22 23:42:32 +0000192 die(_("revision walk setup failed"));
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500193 while ((commit = get_revision(rev)) != NULL)
194 shortlog_add_commit(log, commit);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200195}
196
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200197static int parse_uint(char const **arg, int comma, int defval)
Junio C Hamano3d711d92007-04-08 01:28:00 -0700198{
199 unsigned long ul;
200 int ret;
201 char *endp;
202
203 ul = strtoul(*arg, &endp, 10);
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200204 if (*endp && *endp != comma)
Junio C Hamano3d711d92007-04-08 01:28:00 -0700205 return -1;
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200206 if (ul > INT_MAX)
Junio C Hamano3d711d92007-04-08 01:28:00 -0700207 return -1;
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200208 ret = *arg == endp ? defval : (int)ul;
209 *arg = *endp ? endp + 1 : endp;
Junio C Hamano3d711d92007-04-08 01:28:00 -0700210 return ret;
211}
212
213static const char wrap_arg_usage[] = "-w[<width>[,<indent1>[,<indent2>]]]";
214#define DEFAULT_WRAPLEN 76
215#define DEFAULT_INDENT1 6
216#define DEFAULT_INDENT2 9
217
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200218static int parse_wrap_args(const struct option *opt, const char *arg, int unset)
Junio C Hamano3d711d92007-04-08 01:28:00 -0700219{
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200220 struct shortlog *log = opt->value;
Junio C Hamano3d711d92007-04-08 01:28:00 -0700221
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200222 log->wrap_lines = !unset;
223 if (unset)
224 return 0;
225 if (!arg) {
226 log->wrap = DEFAULT_WRAPLEN;
227 log->in1 = DEFAULT_INDENT1;
228 log->in2 = DEFAULT_INDENT2;
229 return 0;
230 }
Junio C Hamano3d711d92007-04-08 01:28:00 -0700231
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200232 log->wrap = parse_uint(&arg, ',', DEFAULT_WRAPLEN);
233 log->in1 = parse_uint(&arg, ',', DEFAULT_INDENT1);
234 log->in2 = parse_uint(&arg, '\0', DEFAULT_INDENT2);
235 if (log->wrap < 0 || log->in1 < 0 || log->in2 < 0)
236 return error(wrap_arg_usage);
237 if (log->wrap &&
238 ((log->in1 && log->wrap <= log->in1) ||
239 (log->in2 && log->wrap <= log->in2)))
240 return error(wrap_arg_usage);
241 return 0;
Junio C Hamano3d711d92007-04-08 01:28:00 -0700242}
243
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500244void shortlog_init(struct shortlog *log)
245{
246 memset(log, 0, sizeof(*log));
247
Marius Storm-Olsend551a482009-02-08 15:34:27 +0100248 read_mailmap(&log->mailmap, &log->common_repo_prefix);
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500249
Johannes Schindelinc455c872008-07-21 19:03:49 +0100250 log->list.strdup_strings = 1;
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500251 log->wrap = DEFAULT_WRAPLEN;
252 log->in1 = DEFAULT_INDENT1;
253 log->in2 = DEFAULT_INDENT2;
254}
255
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200256int cmd_shortlog(int argc, const char **argv, const char *prefix)
257{
Jeff King64093fc2016-06-13 01:39:28 -0400258 struct shortlog log = { STRING_LIST_INIT_NODUP };
259 struct rev_info rev;
Nguyễn Thái Ngọc Duy773b69b2010-08-05 22:01:37 -0500260 int nongit = !startup_info->have_repository;
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500261
Jeff King64093fc2016-06-13 01:39:28 -0400262 const struct option options[] = {
Linus Torvaldsfbfda152016-10-11 11:45:58 -0700263 OPT_BOOL('c', "committer", &log.committer,
264 N_("Group by committer rather than author")),
Stefan Bellerd5d09d42013-08-03 13:51:19 +0200265 OPT_BOOL('n', "numbered", &log.sort_by_number,
266 N_("sort output according to the number of commits per author")),
267 OPT_BOOL('s', "summary", &log.summary,
268 N_("Suppress commit descriptions, only provides commit count")),
269 OPT_BOOL('e', "email", &log.email,
270 N_("Show the email address of each author")),
René Scharfeb8ade4c2018-08-02 21:18:06 +0200271 { OPTION_CALLBACK, 'w', NULL, &log, N_("<w>[,<i1>[,<i2>]]"),
René Scharfe5f0df442018-08-02 21:18:14 +0200272 N_("Linewrap output"), PARSE_OPT_OPTARG,
René Scharfeb8ade4c2018-08-02 21:18:06 +0200273 &parse_wrap_args },
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200274 OPT_END(),
275 };
276
277 struct parse_opt_ctx_t ctx;
278
Marius Storm-Olsend551a482009-02-08 15:34:27 +0100279 git_config(git_default_config, NULL);
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500280 shortlog_init(&log);
Nguyễn Thái Ngọc Duy2abf3502018-09-21 17:57:38 +0200281 repo_init_revisions(the_repository, &rev, prefix);
Stephen Boyd9ca11692010-12-05 23:57:42 -0800282 parse_options_start(&ctx, argc, argv, prefix, options,
283 PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0);
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200284
285 for (;;) {
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200286 switch (parse_options_step(&ctx, options, shortlog_usage)) {
287 case PARSE_OPT_HELP:
Paul-Sebastian Ungureanu3bb09232018-03-22 20:43:51 +0200288 case PARSE_OPT_ERROR:
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200289 exit(129);
Nguyễn Thái Ngọc Duya92ec7e2018-12-11 16:35:01 +0100290 case PARSE_OPT_COMPLETE:
291 exit(0);
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200292 case PARSE_OPT_DONE:
293 goto parse_done;
294 }
Pierre Habouzit6b61ec02008-07-09 23:38:34 +0200295 parse_revision_opt(&rev, &ctx, options, shortlog_usage);
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200296 }
297parse_done:
298 argc = parse_options_end(&ctx);
299
Martin Ågren4aa01612018-03-14 22:34:19 +0100300 if (nongit && argc > 1) {
301 error(_("too many arguments given outside repository"));
302 usage_with_options(shortlog_usage, options);
303 }
304
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200305 if (setup_revisions(argc, argv, &rev, NULL) != 1) {
Ævar Arnfjörð Bjarmasonab8b53b2011-02-22 23:42:32 +0000306 error(_("unrecognized argument: %s"), argv[1]);
Pierre Habouzit14ec9cb2008-07-09 23:38:33 +0200307 usage_with_options(shortlog_usage, options);
308 }
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200309
Johannes Schindelinb526f8e2008-07-14 19:08:52 +0100310 log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
Will Palmerc1977022010-05-03 22:18:57 -0500311 log.abbrev = rev.abbrev;
Johannes Schindelin7f7d7122016-06-22 17:02:07 +0200312 log.file = rev.diffopt.file;
Johannes Schindelinb526f8e2008-07-14 19:08:52 +0100313
Junio C Hamano3384a2d2007-12-11 10:09:04 -0800314 /* assume HEAD if from a tty */
Jonas Fonsecaabe549e2008-03-14 22:35:24 +0100315 if (!nongit && !rev.pending.nr && isatty(0))
Junio C Hamano3384a2d2007-12-11 10:09:04 -0800316 add_head_to_pending(&rev);
Junio C Hamano0497c622007-03-08 02:12:06 -0800317 if (rev.pending.nr == 0) {
Michele Ballabio37314492010-02-24 21:49:03 +0100318 if (isatty(0))
Ævar Arnfjörð Bjarmasonab8b53b2011-02-22 23:42:32 +0000319 fprintf(stderr, _("(reading log message from standard input)\n"));
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500320 read_from_stdin(&log);
Junio C Hamano0497c622007-03-08 02:12:06 -0800321 }
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200322 else
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500323 get_from_rev(&rev, &log);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200324
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500325 shortlog_output(&log);
Johannes Schindelin7f7d7122016-06-22 17:02:07 +0200326 if (log.file != stdout)
327 fclose(log.file);
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500328 return 0;
329}
330
René Scharfebb96a2c2010-02-19 23:15:01 +0100331static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
332 const struct shortlog *log)
333{
Steffen Prohaska5b597082012-12-11 06:59:21 +0100334 strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
335 strbuf_addch(sb, '\n');
René Scharfebb96a2c2010-02-19 23:15:01 +0100336}
337
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500338void shortlog_output(struct shortlog *log)
339{
340 int i, j;
René Scharfebb96a2c2010-02-19 23:15:01 +0100341 struct strbuf sb = STRBUF_INIT;
342
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500343 if (log->sort_by_number)
René Scharfe1b5294d2016-09-30 01:40:14 +0200344 QSORT(log->list.items, log->list.nr,
Jeff King9b21a342016-01-18 15:02:59 -0500345 log->summary ? compare_by_counter : compare_by_list);
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500346 for (i = 0; i < log->list.nr; i++) {
Jeff King9b21a342016-01-18 15:02:59 -0500347 const struct string_list_item *item = &log->list.items[i];
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500348 if (log->summary) {
Johannes Schindelin0a7b3572016-06-22 17:01:49 +0200349 fprintf(log->file, "%6d\t%s\n",
350 (int)UTIL_TO_INT(item), item->string);
Nicolas Pitreac60c942006-11-21 15:49:45 -0500351 } else {
Jeff King9b21a342016-01-18 15:02:59 -0500352 struct string_list *onelines = item->util;
Johannes Schindelin0a7b3572016-06-22 17:01:49 +0200353 fprintf(log->file, "%s (%d):\n",
354 item->string, onelines->nr);
Johannes Schindelin3714e7c2006-12-22 22:15:59 +0100355 for (j = onelines->nr - 1; j >= 0; j--) {
Johannes Schindelinc455c872008-07-21 19:03:49 +0100356 const char *msg = onelines->items[j].string;
Junio C Hamano3d711d92007-04-08 01:28:00 -0700357
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500358 if (log->wrap_lines) {
René Scharfebb96a2c2010-02-19 23:15:01 +0100359 strbuf_reset(&sb);
360 add_wrapped_shortlog_msg(&sb, msg, log);
Johannes Schindelin0a7b3572016-06-22 17:01:49 +0200361 fwrite(sb.buf, sb.len, 1, log->file);
Junio C Hamano3d711d92007-04-08 01:28:00 -0700362 }
363 else
Johannes Schindelin0a7b3572016-06-22 17:01:49 +0200364 fprintf(log->file, " %s\n", msg);
Johannes Schindelin3714e7c2006-12-22 22:15:59 +0100365 }
Johannes Schindelin0a7b3572016-06-22 17:01:49 +0200366 putc('\n', log->file);
Jeff King9b21a342016-01-18 15:02:59 -0500367 onelines->strdup_strings = 1;
368 string_list_clear(onelines, 0);
369 free(onelines);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200370 }
371
Daniel Barkalow552bcac2008-02-25 18:24:14 -0500372 log->list.items[i].util = NULL;
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200373 }
374
René Scharfebb96a2c2010-02-19 23:15:01 +0100375 strbuf_release(&sb);
Johannes Schindelinc455c872008-07-21 19:03:49 +0100376 log->list.strdup_strings = 1;
377 string_list_clear(&log->list, 1);
Marius Storm-Olsend20d6542009-02-08 15:34:30 +0100378 clear_mailmap(&log->mailmap);
Johannes Schindelinb8ec5922006-10-22 13:23:31 +0200379}