git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC] rev-list --count: separate count for --cherry-mark

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 22, 2011, 12:41 UTC
Message-ID
<df0c562ed0e2255a3cfe581698298a6fe48900ca.1300797575.git.git@drmicha.warpmail.net>

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>
---
I noticed this in passing. It does not break anything and can be done
easily. I would feel strongly positive about it if rev-list --cherry
was faster. Then it would be useful for gitprompt, branch -vv and the like.
 Documentation/rev-list-options.txt |    5 ++++-
 builtin/rev-list.c                 |   10 ++++++++--
 revision.h                         |    1 +
 3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 5c6850f..e092a7c 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -715,7 +715,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 f458cb7..8761e9a 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -51,7 +51,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++;
@@ -402,8 +404,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 ae94860..08900b3 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
-- 
1.7.4.1.511.g72e46
Message 1 of 1 in “rev-list --count: separate count for --cherry-mark”
  1. rev-list --count: separate count for --cherry-markMichael J Gruber, Mar 22, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.