@matheusbsbs / matheus-bagliano / commits / b388e14b89
Fork 0

rev-list --count: separate count for --cherry-mark

When --count is used with --cherry-mark, omit the patch equivalent commits from the count for left and right commits and print the count of equivalent commits separately. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Apr 26, 2011 at 10:24 UTC b388e14b89f0a82b8067b3922a93cf2d1b013ff0
4 files changed +40 -3
Documentation/rev-list-options.txt
+4 -1
@@ -730,7 +730,10 @@ ifdef::git-rev-list[]
730 Print a number stating how many commits would have been
731 listed, and suppress all other output. When used together
732 with '--left-right', instead print the counts for left and
733 - right commits, separated by a tab.
733 + right commits, separated by a tab. When used together with
734 + '--cherry-mark', omit patch equivalent commits from these
735 + counts and print the count for equivalent commits separated
736 + by a tab.
737 endif::git-rev-list[]
738
739
builtin/rev-list.c
+8 -2
@@ -55,7 +55,9 @@ static void show_commit(struct commit *commit, void *data)
55 graph_show_commit(revs->graph);
56
57 if (revs->count) {
58 - if (commit->object.flags & SYMMETRIC_LEFT)
58 + if (commit->object.flags & PATCHSAME)
59 + revs->count_same++;
60 + else if (commit->object.flags & SYMMETRIC_LEFT)
61 revs->count_left++;
62 else
63 revs->count_right++;
@@ -406,8 +408,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
408 &info);
409
410 if (revs.count) {
409 - if (revs.left_right)
411 + if (revs.left_right && revs.cherry_mark)
412 + printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
413 + else if (revs.left_right)
414 printf("%d\t%d\n", revs.count_left, revs.count_right);
415 + else if (revs.cherry_mark)
416 + printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
417 else
418 printf("%d\n", revs.count_left + revs.count_right);
419 }
revision.h
+1
@@ -141,6 +141,7 @@ struct rev_info {
141 /* commit counts */
142 int count_left;
143 int count_right;
144 + int count_same;
145 };
146
147 #define REV_TREE_SAME 0
t/t6007-rev-list-cherry-pick-file.sh
+27
@@ -157,6 +157,33 @@ test_expect_success '--cherry' '
157 test_cmp actual.named expect
158 '
159
160 +cat >expect <<EOF
161 +1 1
162 +EOF
163 +
164 +test_expect_success '--cherry --count' '
165 + git rev-list --cherry --count F...E -- bar > actual &&
166 + test_cmp actual expect
167 +'
168 +
169 +cat >expect <<EOF
170 +2 2
171 +EOF
172 +
173 +test_expect_success '--cherry-mark --count' '
174 + git rev-list --cherry-mark --count F...E -- bar > actual &&
175 + test_cmp actual expect
176 +'
177 +
178 +cat >expect <<EOF
179 +1 1 2
180 +EOF
181 +
182 +test_expect_success '--cherry-mark --left-right --count' '
183 + git rev-list --cherry-mark --left-right --count F...E -- bar > actual &&
184 + test_cmp actual expect
185 +'
186 +
187 test_expect_success '--cherry-pick with independent, but identical branches' '
188 git symbolic-ref HEAD refs/heads/independent &&
189 rm .git/index &&