@matheusbsbs / matheus-bagliano / commits / 9fa3465d6b
Fork 0

Add --log-size to git log to print message size

With this option git-log prints log message size just before the corresponding message. Porcelain tools could use this to speedup parsing of git-log output. Note that size refers to log message only. If also patch content is shown its size is not included. In case it is not possible to know the size upfront size value is set to zero. Signed-off-by: Marco Costalba <mcostalba@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Marco Costalba committed Jul 20, 2007 at 20:15 UTC 9fa3465d6be83c08ed24762c82eb33cb005729f3
4 files changed +15
Documentation/git-log.txt
+7
@@ -64,6 +64,13 @@ include::pretty-options.txt[]
64 --follow::
65 Continue listing the history of a file beyond renames.
66
67 +--log-size::
68 + Before the log message print out its size in bytes. Intended
69 + mainly for porcelain tools consumption. If git is unable to
70 + produce a valid value size is set to zero.
71 + Note that only message is considered, if also a diff is shown
72 + its size is not included.
73 +
74 <paths>...::
75 Show only commits that affect the specified paths.
76
log-tree.c
+3
@@ -295,6 +295,9 @@ void show_log(struct rev_info *opt, const char *sep)
295 if (opt->add_signoff)
296 len = append_signoff(&msgbuf, &msgbuf_len, len,
297 opt->add_signoff);
298 + if (opt->show_log_size)
299 + printf("log size %i\n", len);
300 +
301 printf("%s%s%s", msgbuf, extra, sep);
302 free(msgbuf);
303 }
revision.c
+4
@@ -1150,6 +1150,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1150 die("unknown date format %s", arg);
1151 continue;
1152 }
1153 + if (!strcmp(arg, "--log-size")) {
1154 + revs->show_log_size = 1;
1155 + continue;
1156 + }
1157
1158 /*
1159 * Grepping the commit log
revision.h
+1
@@ -81,6 +81,7 @@ struct rev_info {
81 const char *log_reencode;
82 const char *subject_prefix;
83 int no_inline;
84 + int show_log_size;
85
86 /* Filter by commit log message */
87 struct grep_opt *grep_filter;