git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add --log-size to git log to print message size
@ 2007-07-20 18:15 Marco Costalba
  2007-07-20 18:41 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Costalba @ 2007-07-20 18:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

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>
---

This is take 3 of this patch. In this case has been clearly added that
diff content size is not included.


  Documentation/git-log.txt |    7 +++++++
 log-tree.c                |    3 +++
 revision.c                |    4 ++++
 revision.h                |    1 +
 4 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 63c1dbe..40b9a09 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.
+
 <paths>...::
 	Show only commits that affect the specified paths.

diff --git a/log-tree.c b/log-tree.c
index 8624d5a..2dc6b1b 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_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 28b5f2e..f1cbb1f 100644
--- a/revision.c
+++ b/revision.c
@@ -1149,6 +1149,10 @@ int setup_revisions(int argc, const
  					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 f46b4d5..98a0a8f 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;
-- 
1.5.3.rc2-dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add --log-size to git log to print message size
  2007-07-20 18:15 [PATCH] Add --log-size to git log to print message size Marco Costalba
@ 2007-07-20 18:41 ` Johannes Schindelin
  2007-07-20 20:49   ` Marco Costalba
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2007-07-20 18:41 UTC (permalink / raw)
  To: Marco Costalba; +Cc: Junio C Hamano, Git Mailing List

Hi,

On Fri, 20 Jul 2007, Marco Costalba wrote:

> This is take 3 of this patch. In this case has been clearly added that 
> diff content size is not included.

Two concerns and a half:

- if you do not include the diff content size, don't you need to parse the 
  output anyway?

- what do you do if the underlying Git does not support --log-size? Exit?

- Would it not be much quicker to read the rev-list, and read messages 
  only on demand?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add --log-size to git log to print message size
  2007-07-20 18:41 ` Johannes Schindelin
@ 2007-07-20 20:49   ` Marco Costalba
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Costalba @ 2007-07-20 20:49 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, Git Mailing List

On 7/20/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Fri, 20 Jul 2007, Marco Costalba wrote:
>
> > This is take 3 of this patch. In this case has been clearly added that
> > diff content size is not included.
>
> Two concerns and a half:
>
> - if you do not include the diff content size, don't you need to parse the
>   output anyway?
>

First, dif content is included only when retrieving file history and
not to show revisions at startup that is the main use.

Second, also with diff content I don't parse the message because I
jump directly to the beginning of the diff and, yes, from there I
check for delimiting '\0', so I would say also in that case we have a
speedup, but it's not very important because we are talking of speed
up when you read thousands of revisions, few hundred (as typical in
file histories) are not a problem.

Also because with -p option git log becomes a real bottleneck.


> - what do you do if the underlying Git does not support --log-size? Exit?
>

If for "not support" you mean that underlying Git sets size at zero
(as allowed by specifications) this is of course handled: qgit falls
back on legacy '\0' search. BTW the currently  published version does
exactly that, it has already the shortcut logic, but falls back always
on zero search because the modified git is _currently_ only on my hard
disk.


Otherwise, if you mean that git version is too old, in this case this
is caught by the git version check done always at startup.

Indeed I plan to add this feature only to new qgit4, will not be back
ported to stable qgit-1.5.6

> - Would it not be much quicker to read the rev-list, and read messages
>   only on demand?
>

That's exactly what we are talking about ;-)

 All the output of git-log (no more git-rev-list) is stored in memory
as a raw big binary blob, for quick retrieval, i.e. to avoid calling
an external git command process, but messages are not parsed until are
used. So _this_ is exactly the point of all this patch.

If you mean using git-rev-list without --header options then , also
not considering that currently we use git-log, the speed up is very
small and when you have to show something to the user you always need
to run a git command.

Perhaps this could be accepted (perhaps not ;-) for mouse browsing
through revisions, but what about sub string searching as example on
author or log title fields? probably it would became super slow also
for lists of only few hundred revs.


> Ciao,
> Dscho

Ciao
Marco

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-20 20:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-20 18:15 [PATCH] Add --log-size to git log to print message size Marco Costalba
2007-07-20 18:41 ` Johannes Schindelin
2007-07-20 20:49   ` Marco Costalba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).