diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 63c1dbe812e607..5a90f65b5e9d9c 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -64,6 +64,13 @@ include::pretty-options.txt[] --follow:: Continue listing the history of a file beyond renames. +--log-size:: + Before the log message print out its size in bytes. Intended + mainly for porcelain tools consumption. If git is unable to + produce a valid value size is set to zero. + Note that only message is considered, if also a diff is shown + its size is not included. + ...:: Show only commits that affect the specified paths. diff --git a/log-tree.c b/log-tree.c index 8624d5a39ca311..a6423718e76be3 100644 --- a/log-tree.c +++ b/log-tree.c @@ -295,6 +295,9 @@ void show_log(struct rev_info *opt, const char *sep) if (opt->add_signoff) len = append_signoff(&msgbuf, &msgbuf_len, len, opt->add_signoff); + if (opt->show_log_size) + printf("log size %i\n", len); + printf("%s%s%s", msgbuf, extra, sep); free(msgbuf); } diff --git a/revision.c b/revision.c index 038693caba69a9..7d32a89b0eca85 100644 --- a/revision.c +++ b/revision.c @@ -1150,6 +1150,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch die("unknown date format %s", arg); continue; } + if (!strcmp(arg, "--log-size")) { + revs->show_log_size = 1; + continue; + } /* * Grepping the commit log diff --git a/revision.h b/revision.h index f46b4d55a2c75e..98a0a8f3fa9db4 100644 --- a/revision.h +++ b/revision.h @@ -81,6 +81,7 @@ struct rev_info { const char *log_reencode; const char *subject_prefix; int no_inline; + int show_log_size; /* Filter by commit log message */ struct grep_opt *grep_filter;