Skip to content

Commit 117374f

Browse files
committed
Merge branch 'mg/rev-list-count-cherry'
* mg/rev-list-count-cherry: rev-list --count: separate count for --cherry-mark
2 parents a211e67 + b388e14 commit 117374f

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

Documentation/rev-list-options.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,10 @@ ifdef::git-rev-list[]
730730
Print a number stating how many commits would have been
731731
listed, and suppress all other output. When used together
732732
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.
734737
endif::git-rev-list[]
735738

736739

builtin/rev-list.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ static void show_commit(struct commit *commit, void *data)
5555
graph_show_commit(revs->graph);
5656

5757
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)
5961
revs->count_left++;
6062
else
6163
revs->count_right++;
@@ -406,8 +408,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
406408
&info);
407409

408410
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)
410414
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);
411417
else
412418
printf("%d\n", revs.count_left + revs.count_right);
413419
}

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ struct rev_info {
141141
/* commit counts */
142142
int count_left;
143143
int count_right;
144+
int count_same;
144145
};
145146

146147
#define REV_TREE_SAME 0

t/t6007-rev-list-cherry-pick-file.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,33 @@ test_expect_success '--cherry' '
157157
test_cmp actual.named expect
158158
'
159159

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+
160187
test_expect_success '--cherry-pick with independent, but identical branches' '
161188
git symbolic-ref HEAD refs/heads/independent &&
162189
rm .git/index &&

0 commit comments

Comments
 (0)