git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add --show-size to git log to print message size

From
MCMarco Costalba <mcostalba@gmail.com>
Date
Jul 14, 2007, 16:52 UTC
Message-ID
<e5bfff550707140952hb60735bi95a4f03636c4aa99@mail.gmail.com>

Print message size just before the corresponding message to speedup the parsing by scripts/porcelains tools.

Because git log output is normally read incrementally by porcelain tools, if message size is ignored then an expensive seek of the delimiting char, as example '\0' must be done when parsing the output stream.

With this patch it is possible to avoid an otherwise mandatory seek for '\0' starting from the beginning of log body.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---

This little patch makes great difference in loading performance of our loved ;-) tool....and probably also others.

Please apply.

Thanks Marco

 log-tree.c |    3 +++
 revision.c |    4 ++++
 revision.h |    1 +
 3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 8624d5a..2fb7761 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -295,6 +295,9 @@ void show_log(struct rev_info *opt,
 	if (opt->add_signoff)
  		len = append_signoff(&msgbuf, &msgbuf_len, len,
 				     opt->add_signoff);
+ 	if (opt->show_size)
+		printf("size %i\n", len);
+
  	printf("%s%s%s", msgbuf, extra, sep);
  	free(msgbuf);
 }
diff --git a/revision.c b/revision.c
index 33ee9ee..3850a1e 100644
--- a/revision.c
+++ b/revision.c
@@ -1136,6 +1136,10 @@ int setup_revisions(int argc,
 				continue;
 			}
+			if (!strcmp(arg, "--show-size")) {
+				revs->show_size = 1;
+				continue;
+			}

 			/*
 			 * Grepping the commit log
diff --git a/revision.h b/revision.h
index f46b4d5..584b3f1 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_size;

 	/* Filter by commit log message */
  	struct grep_opt	*grep_filter;
-- 
1.5.3.rc0.81.g1ed84-dirty
Next: Junio C Hamano
Message 1 of 29 in “Add --show-size to git log to print message size”
  1. Add --show-size to git log to print message sizeMarco Costalba, Jul 14, 2007
  2. Junio C HamanoJul 14, 2007
  3. Marco CostalbaJul 14, 2007
  4. Alex RiesenJul 15, 2007
  5. Marco CostalbaJul 15, 2007
  6. Alex RiesenJul 15, 2007
  7. Marco CostalbaJul 15, 2007
  8. Marco CostalbaJul 15, 2007
  9. SeanJul 15, 2007
  10. Marco CostalbaJul 15, 2007
  11. SeanJul 15, 2007
  12. Marco CostalbaJul 15, 2007
  13. SeanJul 15, 2007
  14. Marco CostalbaJul 15, 2007
  15. SeanJul 15, 2007
  16. Marco CostalbaJul 15, 2007
  17. Linus TorvaldsJul 15, 2007
  18. Marco CostalbaJul 15, 2007
  19. Marco CostalbaJul 16, 2007
  20. Alex RiesenJul 16, 2007
  21. Junio C HamanoJul 16, 2007
  22. Marco CostalbaJul 16, 2007
  23. Marco CostalbaJul 16, 2007
  24. Junio C HamanoJul 16, 2007
  25. Marco CostalbaJul 16, 2007
  26. Andy ParkinsJul 17, 2007
  27. Marco CostalbaJul 17, 2007
  28. Junio C HamanoJul 25, 2007
  29. Marco CostalbaJul 25, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.