{"thread":{"id":"9122","subject":"[PATCH] Add --log-size to git log to print message size","startedAt":"2007-07-20T18:15:13Z","lastAt":"2007-07-20T20:49:17Z","messageCount":3,"participants":["Marco Costalba","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"47981","messageId":"e5bfff550707201115v2531434erd9e10a2b816a59bf@mail.gmail.com","threadId":"9122","inReplyTo":null,"subject":"[PATCH] Add --log-size to git log to print message size","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2007-07-20T18:15:13Z","receivedAt":"2007-07-20T18:15:13Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"With this option git-log prints log message size\njust before the corresponding message.\n\nPorcelain tools could use this to speedup parsing\nof git-log output.\n\nNote that size refers to log message only. If also\npatch content is shown its size is not included.\n\nIn case it is not possible to know the size upfront\nsize value is set to zero.\n\nSigned-off-by: Marco Costalba <mcostalba@gmail.com>\n---\n\nThis is take 3 of this patch. In this case has been clearly added that\ndiff content size is not included.\n\n\n  Documentation/git-log.txt |    7 +++++++\n log-tree.c                |    3 +++\n revision.c                |    4 ++++\n revision.h                |    1 +\n 4 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-log.txt b/Documentation/git-log.txt\nindex 63c1dbe..40b9a09 100644\n--- a/Documentation/git-log.txt\n+++ b/Documentation/git-log.txt\n@@ -64,6 +64,13 @@ include::pretty-options.txt[]\n --follow::\n \tContinue listing the history of a file beyond renames.\n\n+--log-size::\n+\tBefore the log message print out its size in bytes. Intended\n+\tmainly for porcelain tools consumption. If git is unable to\n+\tproduce a valid value size is set to zero.\n+\tNote that only message is considered, if also a diff is shown\n+\tits size is not included.\n+\n <paths>...::\n \tShow only commits that affect the specified paths.\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 8624d5a..2dc6b1b 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -295,6 +295,9 @@ void show_log(struct rev_info *opt,\n \tif (opt->add_signoff)\n  \t\tlen = append_signoff(&msgbuf, &msgbuf_len, len,\n \t\t\t\t     opt->add_signoff);\n+ \tif (opt->show_log_size)\n+\t\tprintf(\"log size %i\\n\", len);\n+\n  \tprintf(\"%s%s%s\", msgbuf, extra, sep);\n  \tfree(msgbuf);\n }\ndiff --git a/revision.c b/revision.c\nindex 28b5f2e..f1cbb1f 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1149,6 +1149,10 @@ int setup_revisions(int argc, const\n  \t\t\t\t\tdie(\"unknown date format %s\", arg);\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--log-size\")) {\n+\t\t\t\trevs->show_log_size = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n\n \t\t\t/*\n \t\t\t * Grepping the commit log\ndiff --git a/revision.h b/revision.h\nindex f46b4d5..98a0a8f 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -81,6 +81,7 @@ struct rev_info {\n  \tconst char\t*log_reencode;\n  \tconst char\t*subject_prefix;\n \tint\t\tno_inline;\n+\tint\t\tshow_log_size;\n\n \t/* Filter by commit log message */\n  \tstruct grep_opt\t*grep_filter;\n-- \n1.5.3.rc2-dirty\n"},{"id":"47985","messageId":"Pine.LNX.4.64.0707201939170.14781@racer.site","threadId":"9122","inReplyTo":"e5bfff550707201115v2531434erd9e10a2b816a59bf@mail.gmail.com","subject":"Re: [PATCH] Add --log-size to git log to print message size","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-20T18:41:08Z","receivedAt":"2007-07-20T18:41:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 20 Jul 2007, Marco Costalba wrote:\n\n> This is take 3 of this patch. In this case has been clearly added that \n> diff content size is not included.\n\nTwo concerns and a half:\n\n- if you do not include the diff content size, don't you need to parse the \n  output anyway?\n\n- what do you do if the underlying Git does not support --log-size? Exit?\n\n- Would it not be much quicker to read the rev-list, and read messages \n  only on demand?\n\nCiao,\nDscho\n"},{"id":"47992","messageId":"e5bfff550707201349i52363837o739d27c6c4dc3ec8@mail.gmail.com","threadId":"9122","inReplyTo":"Pine.LNX.4.64.0707201939170.14781@racer.site","subject":"Re: [PATCH] Add --log-size to git log to print message size","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2007-07-20T20:49:17Z","receivedAt":"2007-07-20T20:49:17Z","isPatch":true,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On 7/20/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Fri, 20 Jul 2007, Marco Costalba wrote:\n>\n> > This is take 3 of this patch. In this case has been clearly added that\n> > diff content size is not included.\n>\n> Two concerns and a half:\n>\n> - if you do not include the diff content size, don't you need to parse the\n>   output anyway?\n>\n\nFirst, dif content is included only when retrieving file history and\nnot to show revisions at startup that is the main use.\n\nSecond, also with diff content I don't parse the message because I\njump directly to the beginning of the diff and, yes, from there I\ncheck for delimiting '\\0', so I would say also in that case we have a\nspeedup, but it's not very important because we are talking of speed\nup when you read thousands of revisions, few hundred (as typical in\nfile histories) are not a problem.\n\nAlso because with -p option git log becomes a real bottleneck.\n\n\n> - what do you do if the underlying Git does not support --log-size? Exit?\n>\n\nIf for \"not support\" you mean that underlying Git sets size at zero\n(as allowed by specifications) this is of course handled: qgit falls\nback on legacy '\\0' search. BTW the currently  published version does\nexactly that, it has already the shortcut logic, but falls back always\non zero search because the modified git is _currently_ only on my hard\ndisk.\n\n\nOtherwise, if you mean that git version is too old, in this case this\nis caught by the git version check done always at startup.\n\nIndeed I plan to add this feature only to new qgit4, will not be back\nported to stable qgit-1.5.6\n\n> - Would it not be much quicker to read the rev-list, and read messages\n>   only on demand?\n>\n\nThat's exactly what we are talking about ;-)\n\n All the output of git-log (no more git-rev-list) is stored in memory\nas a raw big binary blob, for quick retrieval, i.e. to avoid calling\nan external git command process, but messages are not parsed until are\nused. So _this_ is exactly the point of all this patch.\n\nIf you mean using git-rev-list without --header options then , also\nnot considering that currently we use git-log, the speed up is very\nsmall and when you have to show something to the user you always need\nto run a git command.\n\nPerhaps this could be accepted (perhaps not ;-) for mouse browsing\nthrough revisions, but what about sub string searching as example on\nauthor or log title fields? probably it would became super slow also\nfor lists of only few hundred revs.\n\n\n> Ciao,\n> Dscho\n\nCiao\nMarco\n"}]}