{"thread":{"id":"27183","subject":"[PATCH] rev-list --count: separate count for --cherry-mark","startedAt":"2011-04-26T08:24:29Z","lastAt":"2011-04-26T17:37:30Z","messageCount":2,"participants":["Michael J Gruber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166363","messageId":"3e743b672c3e20a245055e47671bc1af1039b60a.1303806237.git.git@drmicha.warpmail.net","threadId":"27183","inReplyTo":null,"subject":"[PATCH] rev-list --count: separate count for --cherry-mark","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-04-26T08:24:29Z","receivedAt":"2011-04-26T08:24:29Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"When --count is used with --cherry-mark, omit the patch equivalent\ncommits from the count for left and right commits and print the count of\nequivalent commits separately.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nI noticed this in passing. It does not break anything and can be done\neasily. It might even be useful for gitprompt, branch -vv and the like.\n\nResent for the new cycle.\n---\n Documentation/rev-list-options.txt   |    5 ++++-\n builtin/rev-list.c                   |   10 ++++++++--\n revision.h                           |    1 +\n t/t6007-rev-list-cherry-pick-file.sh |   27 +++++++++++++++++++++++++++\n 4 files changed, 40 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 5c6850f..e092a7c 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -715,7 +715,10 @@ ifdef::git-rev-list[]\n \tPrint a number stating how many commits would have been\n \tlisted, and suppress all other output.  When used together\n \twith '--left-right', instead print the counts for left and\n-\tright commits, separated by a tab.\n+\tright commits, separated by a tab. When used together with\n+\t'--cherry-mark', omit patch equivalent commits from these\n+\tcounts and print the count for equivalent commits separated\n+\tby a tab.\n endif::git-rev-list[]\n \n \ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex f458cb7..8761e9a 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -51,7 +51,9 @@ static void show_commit(struct commit *commit, void *data)\n \tgraph_show_commit(revs->graph);\n \n \tif (revs->count) {\n-\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n+\t\tif (commit->object.flags & PATCHSAME)\n+\t\t\trevs->count_same++;\n+\t\telse if (commit->object.flags & SYMMETRIC_LEFT)\n \t\t\trevs->count_left++;\n \t\telse\n \t\t\trevs->count_right++;\n@@ -402,8 +404,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t\t     &info);\n \n \tif (revs.count) {\n-\t\tif (revs.left_right)\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}\ndiff --git a/revision.h b/revision.h\nindex ae94860..08900b3 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -141,6 +141,7 @@ struct rev_info {\n \t/* commit counts */\n \tint count_left;\n \tint count_right;\n+\tint count_same;\n };\n \n #define REV_TREE_SAME\t\t0\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex cacf3de..28d4f6b 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -157,6 +157,33 @@ test_expect_success '--cherry' '\n \ttest_cmp actual.named expect\n '\n \n+cat >expect <<EOF\n+1\t1\n+EOF\n+\n+test_expect_success '--cherry --count' '\n+\tgit rev-list --cherry --count F...E -- bar > actual &&\n+\ttest_cmp actual expect\n+'\n+\n+cat >expect <<EOF\n+2\t2\n+EOF\n+\n+test_expect_success '--cherry-mark --count' '\n+\tgit rev-list --cherry-mark --count F...E -- bar > actual &&\n+\ttest_cmp actual expect\n+'\n+\n+cat >expect <<EOF\n+1\t1\t2\n+EOF\n+\n+test_expect_success '--cherry-mark --left-right --count' '\n+\tgit rev-list --cherry-mark --left-right --count F...E -- bar > actual &&\n+\ttest_cmp actual expect\n+'\n+\n test_expect_success '--cherry-pick with independent, but identical branches' '\n \tgit symbolic-ref HEAD refs/heads/independent &&\n \trm .git/index &&\n-- \n1.7.5.270.gafca7\n"},{"id":"166400","messageId":"7vwrigewx1.fsf@alter.siamese.dyndns.org","threadId":"27183","inReplyTo":"3e743b672c3e20a245055e47671bc1af1039b60a.1303806237.git.git@drmicha.warpmail.net","subject":"Re: [PATCH] rev-list --count: separate count for --cherry-mark","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-26T17:37:30Z","receivedAt":"2011-04-26T17:37:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> When --count is used with --cherry-mark, omit the patch equivalent\n> commits from the count for left and right commits and print the count of\n> equivalent commits separately.\n>\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n> I noticed this in passing. It does not break anything and can be done\n> easily. It might even be useful for gitprompt, branch -vv and the like.\n\nThis is in the same spirit as your earlier change to not count filtered\ncommits, right?  Sensible.\n"}]}