From: "Marco Costalba" <mcostalba@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: "Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH] Add --show-size to git log to print message size
Date: Mon, 16 Jul 2007 19:50:58 +0200 [thread overview]
Message-ID: <e5bfff550707161050w5751c63fnfa86312c86eaa552@mail.gmail.com> (raw)
In-Reply-To: <7vodiehko7.fsf@assigned-by-dhcp.cox.net>
On 7/14/07, Junio C Hamano <gitster@pobox.com> wrote:
>
> The current code spits out a log message after formatting it in
> its entirety in core, so we happen to have its size upfront.
> Having to say the size upfront means we close the door for
> alternative implementations that stream the log formatting
> processing.
>
This is a better named patch that try also to easy your correct point
about alternative implementations, in particular a value of zero is
reserved in case git is unable to satisfy the request, so that tools
can fallback on standard '\0' searching.
After inspecting diff.c code I made up my mind only log message can be
sized upfront, diff ocntent is printed by a bunch of printf, fwrite,
fputs, putchar and so on and it's impossible to know the size in
advance.
------------------- cut -------------------
Subject: [PATCH] Add --log-size to git log to print message size
Print message size just before the corresponding message.
Because git log output is normally read incrementally by
porcelain tools, if message size is ignored then an
expensive seek of a 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.
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>
---
Documentation/git-log.txt | 5 +++++
log-tree.c | 3 +++
revision.c | 4 ++++
revision.h | 1 +
4 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 63c1dbe..b539f50 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -64,6 +64,11 @@ 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.
+
<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
next prev parent reply other threads:[~2007-07-16 17:51 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-14 16:52 [PATCH] Add --show-size to git log to print message size Marco Costalba
2007-07-14 19:03 ` Junio C Hamano
2007-07-14 20:46 ` Marco Costalba
2007-07-15 9:35 ` Alex Riesen
2007-07-15 10:06 ` Marco Costalba
2007-07-15 10:48 ` Alex Riesen
2007-07-15 11:32 ` Marco Costalba
2007-07-15 12:29 ` Marco Costalba
2007-07-15 12:35 ` Sean
2007-07-15 14:58 ` Marco Costalba
2007-07-15 15:04 ` Sean
2007-07-15 15:58 ` Marco Costalba
2007-07-15 16:16 ` Sean
2007-07-15 16:27 ` Marco Costalba
2007-07-15 16:34 ` Sean
2007-07-15 16:54 ` Marco Costalba
2007-07-15 18:14 ` Linus Torvalds
2007-07-15 18:45 ` Marco Costalba
2007-07-16 12:04 ` Marco Costalba
2007-07-16 12:31 ` Alex Riesen
2007-07-16 17:50 ` Junio C Hamano
2007-07-16 17:55 ` Marco Costalba
2007-07-16 18:02 ` Marco Costalba
2007-07-16 22:37 ` Junio C Hamano
2007-07-16 17:50 ` Marco Costalba [this message]
2007-07-17 7:49 ` Andy Parkins
2007-07-17 16:36 ` Marco Costalba
2007-07-25 4:03 ` Junio C Hamano
2007-07-25 9:38 ` Marco Costalba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5bfff550707161050w5751c63fnfa86312c86eaa552@mail.gmail.com \
--to=mcostalba@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).