aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2011-04-26 10:24:29 +0200
committerJunio C Hamano <gitster@pobox.com>2011-04-26 13:13:20 -0700
commitb388e14b89f0a82b8067b3922a93cf2d1b013ff0 (patch)
treede39c28c8604f4c03270d50a1c3dcf49ec9cf196
parentec014eac0e9e6f30cbbca616090fa2ecf74797e7 (diff)
downloadgit-b388e14b89f0a82b8067b3922a93cf2d1b013ff0.tar.gz
git-b388e14b89f0a82b8067b3922a93cf2d1b013ff0.tar.xz
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>
-rw-r--r--Documentation/rev-list-options.txt5
-rw-r--r--builtin/rev-list.c10
-rw-r--r--revision.h1
-rwxr-xr-xt/t6007-rev-list-cherry-pick-file.sh27
4 files changed, 40 insertions, 3 deletions
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 73111bb05..52bae31fc 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -730,7 +730,10 @@ ifdef::git-rev-list[]
Print a number stating how many commits would have been
listed, and suppress all other output. When used together
with '--left-right', instead print the counts for left and
- right commits, separated by a tab.
+ right commits, separated by a tab. When used together with
+ '--cherry-mark', omit patch equivalent commits from these
+ counts and print the count for equivalent commits separated
+ by a tab.
endif::git-rev-list[]
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 9bfb94201..4be66998f 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -55,7 +55,9 @@ static void show_commit(struct commit *commit, void *data)
graph_show_commit(revs->graph);
if (revs->count) {
- if (commit->object.flags & SYMMETRIC_LEFT)
+ if (commit->object.flags & PATCHSAME)
+ revs->count_same++;
+ else if (commit->object.flags & SYMMETRIC_LEFT)
revs->count_left++;
else
revs->count_right++;
@@ -406,8 +408,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
&info);
if (revs.count) {
- if (revs.left_right)
+ if (revs.left_right && revs.cherry_mark)
+ printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
+ else if (revs.left_right)
printf("%d\t%d\n", revs.count_left, revs.count_right);
+ else if (revs.cherry_mark)
+ printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
else
printf("%d\n", revs.count_left + revs.count_right);
}
diff --git a/revision.h b/revision.h
index 9fd8f3016..bca994797 100644
--- a/revision.h
+++ b/revision.h
@@ -141,6 +141,7 @@ struct rev_info {
/* commit counts */
int count_left;
int count_right;
+ int count_same;
};
#define REV_TREE_SAME 0
diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh
index cacf3de6c..28d4f6b25 100755
--- a/t/t6007-rev-list-cherry-pick-file.sh
+++ b/t/t6007-rev-list-cherry-pick-file.sh
@@ -157,6 +157,33 @@ test_expect_success '--cherry' '
test_cmp actual.named expect
'
+cat >expect <<EOF
+1 1
+EOF
+
+test_expect_success '--cherry --count' '
+ git rev-list --cherry --count F...E -- bar > actual &&
+ test_cmp actual expect
+'
+
+cat >expect <<EOF
+2 2
+EOF
+
+test_expect_success '--cherry-mark --count' '
+ git rev-list --cherry-mark --count F...E -- bar > actual &&
+ test_cmp actual expect
+'
+
+cat >expect <<EOF
+1 1 2
+EOF
+
+test_expect_success '--cherry-mark --left-right --count' '
+ git rev-list --cherry-mark --left-right --count F...E -- bar > actual &&
+ test_cmp actual expect
+'
+
test_expect_success '--cherry-pick with independent, but identical branches' '
git symbolic-ref HEAD refs/heads/independent &&
rm .git/index &&