mcostalba committed 9fa3465

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 <>
Signed-off-by: Junio C Hamano <>

Comments (0)

Files changed (4)


 	Continue listing the history of a file beyond renames.
+	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.
 	if (opt->add_signoff)
 		len = append_signoff(&msgbuf, &msgbuf_len, len,
+	if (opt->show_log_size)
+		printf("log size %i\n", len);
 	printf("%s%s%s", msgbuf, extra, sep);
 					die("unknown date format %s", arg);
+			if (!strcmp(arg, "--log-size")) {
+				revs->show_log_size = 1;
+				continue;
+			}
 			 * Grepping the commit log
 	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;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.