{"thread":{"id":"39764","subject":"[PATCH 1/4] list-object: add get_commit_count function","startedAt":"2015-07-02T05:38:53Z","lastAt":"2015-07-03T18:36:53Z","messageCount":10,"participants":["Lawrence Siebert","Remi Galan Alfonso","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"265380","messageId":"1435815536-30611-1-git-send-email-lawrencesiebert@gmail.com","threadId":"39764","inReplyTo":null,"subject":"[PATCH 1/4] list-object: add get_commit_count function","fromName":"Lawrence Siebert","fromEmail":"lawrencesiebert@gmail.com","sentAt":"2015-07-02T05:38:53Z","receivedAt":"2015-07-02T05:38:53Z","isPatch":true,"sender":{"key":"lawrencesiebert@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45034?v=4"},"body":"Moving commit counting from rev-list into list-object which is a step\ntoward letting git log do counting as well.\n\nSigned-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>\n---\n builtin/rev-list.c | 12 ++----------\n list-objects.c     | 14 ++++++++++++++\n list-objects.h     |  1 +\n 3 files changed, 17 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex ff84a82..7b091db 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -388,16 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \n \ttraverse_commit_list(&revs, show_commit, show_object, &info);\n \n-\tif (revs.count) {\n-\t\tif (revs.left_right && revs.cherry_mark)\n-\t\t\tprintf(\"%d\\t%d\\t%d\\n\", revs.count_left, revs.count_right, revs.count_same);\n-\t\telse if (revs.left_right)\n-\t\t\tprintf(\"%d\\t%d\\n\", revs.count_left, revs.count_right);\n-\t\telse if (revs.cherry_mark)\n-\t\t\tprintf(\"%d\\t%d\\n\", revs.count_left + revs.count_right, revs.count_same);\n-\t\telse\n-\t\t\tprintf(\"%d\\n\", revs.count_left + revs.count_right);\n-\t}\n+\tif (revs.count) \n+\t\tget_commit_count(&revs);  \n \n \treturn 0;\n }\ndiff --git a/list-objects.c b/list-objects.c\nindex 41736d2..6f76301 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -234,3 +234,17 @@ void traverse_commit_list(struct rev_info *revs,\n \tobject_array_clear(&revs->pending);\n \tstrbuf_release(&base);\n }\n+\n+void get_commit_count(struct rev_info * revs) {\n+\tif (revs->count) {\n+\t\tif (revs->left_right && revs->cherry_mark)\n+\t\t\tprintf(\"%d\\t%d\\t%d\\n\", revs->count_left, revs->count_right, revs->count_same);\n+\t\telse if (revs->left_right)\n+\t\t\tprintf(\"%d\\t%d\\n\", revs->count_left, revs->count_right);\n+\t\telse if (revs->cherry_mark)\n+\t\t\tprintf(\"%d\\t%d\\n\", revs->count_left + revs->count_right, revs->count_same);\n+\t\telse\n+\t\t\tprintf(\"%d\\n\", revs->count_left + revs->count_right);\n+\t}\n+\treturn;\n+}\ndiff --git a/list-objects.h b/list-objects.h\nindex 136a1da..d28c1f3 100644\n--- a/list-objects.h\n+++ b/list-objects.h\n@@ -7,5 +7,6 @@ void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, voi\n \n typedef void (*show_edge_fn)(struct commit *);\n void mark_edges_uninteresting(struct rev_info *, show_edge_fn);\n+void get_commit_count(struct rev_info * revs);\n \n #endif\n-- \n1.9.1\n"},{"id":"265381","messageId":"1435815536-30611-2-git-send-email-lawrencesiebert@gmail.com","threadId":"39764","inReplyTo":"1435815536-30611-1-git-send-email-lawrencesiebert@gmail.com","subject":"[PATCH 2/4] log: add --count option to git log","fromName":"Lawrence Siebert","fromEmail":"lawrencesiebert@gmail.com","sentAt":"2015-07-02T05:38:54Z","receivedAt":"2015-07-02T05:38:54Z","isPatch":true,"sender":{"key":"lawrencesiebert@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45034?v=4"},"body":"adds --count from git rev-list to git log, without --use-bitmap-index\nfor the moment.\n\nSigned-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>\n---\n builtin/log.c | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 8781049..ce6df1e 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -25,6 +25,7 @@\n #include \"version.h\"\n #include \"mailmap.h\"\n #include \"gpg-interface.h\"\n+#include \"list-objects.h\"\n \n /* Set a default date-time format for git log (\"log.date\" config variable) */\n static const char *default_date_mode = NULL;\n@@ -317,12 +318,40 @@ static void finish_early_output(struct rev_info *rev)\n \tshow_early_header(rev, \"done\", n);\n }\n \n+static void show_object(struct object *obj,\n+\t\t\tconst struct name_path *path, const char *component,\n+\t\t\tvoid *cb_data)\n+{\n+\treturn;\n+}\n+\n+static void show_commit(struct commit *commit, void *data)\n+{\n+\tstruct rev_info *revs = (struct rev_info *)data;\n+\tif (commit->object.flags & PATCHSAME)\n+\t\trevs->count_same++;\n+\telse if (commit->object.flags & SYMMETRIC_LEFT)\n+\t\trevs->count_left++;\n+\telse\n+\t\trevs->count_right++;\n+\tif (commit->parents) {\n+\t\tfree_commit_list(commit->parents);\n+\t\tcommit->parents = NULL;\n+\t}\n+\tfree_commit_buffer(commit);\n+}\n+\n static int cmd_log_walk(struct rev_info *rev)\n {\n \tstruct commit *commit;\n \tint saved_nrl = 0;\n \tint saved_dcctc = 0;\n \n+\tif (rev->count) {\n+\t\tprepare_revision_walk(rev);\t\n+\t\ttraverse_commit_list(rev, show_commit, show_object, rev);\n+\t\tget_commit_count(rev);\n+\t}\n \tif (rev->early_output)\n \t\tsetup_early_output(rev);\n \n-- \n1.9.1\n"},{"id":"265383","messageId":"1435815536-30611-3-git-send-email-lawrencesiebert@gmail.com","threadId":"39764","inReplyTo":"1435815536-30611-1-git-send-email-lawrencesiebert@gmail.com","subject":"[PATCH 3/4] log --count: added test","fromName":"Lawrence Siebert","fromEmail":"lawrencesiebert@gmail.com","sentAt":"2015-07-02T05:38:55Z","receivedAt":"2015-07-02T05:38:55Z","isPatch":true,"sender":{"key":"lawrencesiebert@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45034?v=4"},"body":"added test comparing output between git log --count HEAD and\ngit rev-list --count HEAD\n\nSigned-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>\n---\n t/t4202-log.sh | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 1b2e981..077952b 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -871,4 +871,11 @@ test_expect_success 'log --graph --no-walk is forbidden' '\n \ttest_must_fail git log --graph --no-walk\n '\n \n+test_expect_success 'log --count' '\n+\tgit log --count HEAD > actual &&\n+\tgit\trev-list --count HEAD > expect &&\n+\ttest_cmp expect actual\n+'\t\n+\t\n+\n test_done\n-- \n1.9.1\n"},{"id":"265382","messageId":"1435815536-30611-4-git-send-email-lawrencesiebert@gmail.com","threadId":"39764","inReplyTo":"1435815536-30611-1-git-send-email-lawrencesiebert@gmail.com","subject":"[PATCH 4/4] git-log: update man documentation for --count","fromName":"Lawrence Siebert","fromEmail":"lawrencesiebert@gmail.com","sentAt":"2015-07-02T05:38:56Z","receivedAt":"2015-07-02T05:38:56Z","isPatch":true,"sender":{"key":"lawrencesiebert@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45034?v=4"},"body":"I'm not altogether sure the best way to update the internal usage\nfrom git-log -h, but this at least updates the man page.\n\nSigned-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>\n---\n Documentation/git-log.txt          | 2 ++\n Documentation/rev-list-options.txt | 2 +-\n 2 files changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-log.txt b/Documentation/git-log.txt\nindex 5692945..0e10e44 100644\n--- a/Documentation/git-log.txt\n+++ b/Documentation/git-log.txt\n@@ -90,6 +90,8 @@ include::line-range-format.txt[]\n Paths may need to be prefixed with ``\\-- '' to separate them from\n options or the revision range, when confusion arises.\n \n+\n+:git-log: 1\n include::rev-list-options.txt[]\n \n include::pretty-formats.txt[]\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 77ac439..f4e15fb 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -797,7 +797,7 @@ This implies the `--topo-order` option by default, but the\n \tin between them in that case. If `<barrier>` is specified, it\n \tis the string that will be shown instead of the default one.\n \n-ifdef::git-rev-list[]\n+ifdef::git-log,git-rev-list[]\n --count::\n \tPrint a number stating how many commits would have been\n \tlisted, and suppress all other output.  When used together\n-- \n1.9.1\n"},{"id":"265386","messageId":"134930107.140053.1435828168932.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39764","inReplyTo":"1435815536-30611-3-git-send-email-lawrencesiebert@gmail.com","subject":"Re: [PATCH 3/4] log --count: added test","fromName":"Remi Galan Alfonso","fromEmail":"remi.galan-alfonso@ensimag.grenoble-inp.fr","sentAt":"2015-07-02T09:09:28Z","receivedAt":"2015-07-02T09:09:28Z","isPatch":true,"sender":{"key":"remi.galan-alfonso@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/12509162?v=4"},"body":"Hi Lawrence,\n\nLawrence Siebert <lawrencesiebert@gmail.com> writes:\n> +test_expect_success 'log --count' '\n> +        git log --count HEAD > actual &&\n> +        git        rev-list --count HEAD > expect &&\n\nWhy the huge space here between 'git' and 'rev-list'?\nAlso no space after the redirection ('>'), it should be '>actual' and\n'>expect'.\n\n> +        test_cmp expect actual\n> +'        \n> +        \n\nIn the mail I see some trailing whitespace after the last two lines.\nI can't apply it myself before some time, so I can't see if 'git am'\nwarns me about trailing whitespace.\nYou can use 'git log --check' to see the trailing whitespace in your\ncommits.\nI'll look if I see some trailing whitespace in your other parts of the\npatch but I might miss some.\n\nRémi\n"},{"id":"265387","messageId":"1192822907.140145.1435828413424.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39764","inReplyTo":"1435815536-30611-1-git-send-email-lawrencesiebert@gmail.com","subject":"Re: [PATCH 1/4] list-object: add get_commit_count function","fromName":"Remi Galan Alfonso","fromEmail":"remi.galan-alfonso@ensimag.grenoble-inp.fr","sentAt":"2015-07-02T09:13:33Z","receivedAt":"2015-07-02T09:13:33Z","isPatch":true,"sender":{"key":"remi.galan-alfonso@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/12509162?v=4"},"body":"Lawrence Siebert <lawrencesiebert@gmail.com> writes:\n> +                get_commit_count(&revs);  \n\nThere's trailing whitespace here.\n(See my message in 3/4)\n\nRémi\n"},{"id":"265388","messageId":"167999398.140205.1435828465233.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39764","inReplyTo":"1435815536-30611-2-git-send-email-lawrencesiebert@gmail.com","subject":"Re: [PATCH 2/4] log: add --count option to git log","fromName":"Remi Galan Alfonso","fromEmail":"remi.galan-alfonso@ensimag.grenoble-inp.fr","sentAt":"2015-07-02T09:14:25Z","receivedAt":"2015-07-02T09:14:25Z","isPatch":true,"sender":{"key":"remi.galan-alfonso@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/12509162?v=4"},"body":"Lawrence Siebert <lawrencesiebert@gmail.com> writes:\n> +                prepare_revision_walk(rev);        \n\nThere's trailing whitespace here.\n(See my message in 3/4)\n\nRémi\n"},{"id":"265440","messageId":"CAKDoJU7uu3wXszV=Cq115CegRR2QQdGAvMpjXr4+qYU-fmEN4g@mail.gmail.com","threadId":"39764","inReplyTo":"167999398.140205.1435828465233.JavaMail.zimbra@ensimag.grenoble-inp.fr","subject":"Re: [PATCH 2/4] log: add --count option to git log","fromName":"Lawrence Siebert","fromEmail":"lawrencesiebert@gmail.com","sentAt":"2015-07-02T23:45:28Z","receivedAt":"2015-07-02T23:45:28Z","isPatch":true,"sender":{"key":"lawrencesiebert@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45034?v=4"},"body":"Thanks.  I've modified my vim config to avoid this happening again,\nand i'll submit a fixed version of these patches.\n\nI'd love if there was a precommit hook to test for this.\n\nLawrence\n\nOn Thu, Jul 2, 2015 at 2:14 AM, Remi Galan Alfonso\n<remi.galan-alfonso@ensimag.grenoble-inp.fr> wrote:\n> Lawrence Siebert <lawrencesiebert@gmail.com> writes:\n>> +                prepare_revision_walk(rev);\n>\n> There's trailing whitespace here.\n> (See my message in 3/4)\n>\n> Rémi\n\n\n\n-- \nAbout Me: http://about.me/lawrencesiebert\nConstantly Coding: http://constantcoding.blogspot.com\n"},{"id":"265470","messageId":"xmqqtwtl3zd7.fsf@gitster.dls.corp.google.com","threadId":"39764","inReplyTo":"1435815536-30611-1-git-send-email-lawrencesiebert@gmail.com","subject":"Re: [PATCH 1/4] list-object: add get_commit_count function","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-03T17:49:40Z","receivedAt":"2015-07-03T17:49:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lawrence Siebert <lawrencesiebert@gmail.com> writes:\n\n> Moving commit counting from rev-list into list-object which is a step\n> toward letting git log do counting as well.\n>\n> Signed-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>\n> ---\n\nNo way.  Look at the things provided by list-objects.c API.  They\nare not about formatting outputs.  printf() calls do not belong\nthere.\n"},{"id":"265476","messageId":"20150703183653.GA11183@peff.net","threadId":"39764","inReplyTo":"xmqqtwtl3zd7.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/4] list-object: add get_commit_count function","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-07-03T18:36:53Z","receivedAt":"2015-07-03T18:36:53Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 03, 2015 at 10:49:40AM -0700, Junio C Hamano wrote:\n\n> Lawrence Siebert <lawrencesiebert@gmail.com> writes:\n> \n> > Moving commit counting from rev-list into list-object which is a step\n> > toward letting git log do counting as well.\n> >\n> > Signed-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>\n> > ---\n> \n> No way.  Look at the things provided by list-objects.c API.  They\n> are not about formatting outputs.  printf() calls do not belong\n> there.\n\nMoreover, if we are going to provide an abstracted function to show the\ncommit count, we would also need to provide one to _create_ the count.\nIOW, this get_commit_count, wherever it goes, should be accompanied by\nthe matching code that is put into \"show_commit\" in patch 2.\n\n-Peff\n"}]}