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

[PATCHv3 06/10] revision.c: introduce --cherry-mark

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 10, 2011, 14:44 UTC
Message-ID
<c17a82478307a5a29455de09232087b17435c52a.1299767413.git.git@drmicha.warpmail.net>
In-Reply-To
<4D78AC8B.7010308@drmicha.warpmail.net>

Introduce --cherry-mark for marking those commits which "--cherry-pick" would drop. The marker for those commits is '=' because '-' denotes a boundary commit already, even though 'git cherry' uses it.

Nonequivalent commits are denoted '+' unless '--left-right' is used.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 revision.c |   19 +++++++++++++++++--
 revision.h |    4 +++-
 2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/revision.c b/revision.c
index 0de1608..864bc9b 100644
--- a/revision.c
+++ b/revision.c
@@ -535,6 +535,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 	int left_count = 0, right_count = 0;
 	int left_first;
 	struct patch_ids ids;
+	unsigned cherry_flag;
 
 	/* First count the commits on the left and on the right */
 	for (p = list; p; p = p->next) {
@@ -576,6 +577,8 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 		commit->util = add_commit_patch_id(commit, &ids);
 	}
 
+	cherry_flag = revs->cherry_mark ? PATCHSAME : SHOWN;
+
 	/* Check the other side */
 	for (p = list; p; p = p->next) {
 		struct commit *commit = p->item;
@@ -598,7 +601,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 		if (!id)
 			continue;
 		id->seen = 1;
-		commit->object.flags |= SHOWN;
+		commit->object.flags |= cherry_flag;
 	}
 
 	/* Now check the original side for seen ones */
@@ -610,7 +613,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 		if (!ent)
 			continue;
 		if (ent->seen)
-			commit->object.flags |= SHOWN;
+			commit->object.flags |= cherry_flag;
 		commit->util = NULL;
 	}
 
@@ -1293,7 +1296,15 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		revs->right_only = 1;
 	} else if (!strcmp(arg, "--count")) {
 		revs->count = 1;
+	} else if (!strcmp(arg, "--cherry-mark")) {
+		if (revs->cherry_pick && !revs->cherry-mark)
+			die("--cherry-mark is incompatible with --cherry-pick");
+		revs->cherry_mark = 1;
+		revs->cherry_pick = 1;
+		revs->limited = 1; /* needs limit_list() */
 	} else if (!strcmp(arg, "--cherry-pick")) {
+		if (revs->cherry_mark)
+			die("--cherry-pick is incompatible with --cherry-mark");
 		revs->cherry_pick = 1;
 		revs->limited = 1;
 	} else if (!strcmp(arg, "--objects")) {
@@ -2270,6 +2281,8 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
 		return "-";
 	else if (commit->object.flags & UNINTERESTING)
 		return "^";
+	else if (commit->object.flags & PATCHSAME)
+		return "=";
 	else if (!revs || revs->left_right) {
 		if (commit->object.flags & SYMMETRIC_LEFT)
 			return "<";
@@ -2277,5 +2290,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
 			return ">";
 	} else if (revs->graph)
 		return "*";
+	else if (revs->cherry_mark)
+		return "+";
 	return "";
 }
diff --git a/revision.h b/revision.h
index 0e4b35e..d38f135 100644
--- a/revision.h
+++ b/revision.h
@@ -14,7 +14,8 @@
 #define CHILD_SHOWN	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
-#define ALL_REV_FLAGS	((1u<<9)-1)
+#define PATCHSAME	(1u<<9)
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
 #define DECORATE_SHORT_REFS	1
 #define DECORATE_FULL_REFS	2
@@ -68,6 +69,7 @@ struct rev_info {
 			reverse:1,
 			reverse_output_stage:1,
 			cherry_pick:1,
+			cherry_mark:1,
 			bisect:1,
 			ancestry_path:1,
 			first_parent_only:1;
-- 
1.7.4.1.317.gf445f
Previous: Michael J GruberNext: Michael J Gruber
Message 23 of 30 in “[PATCHv2 0/9] --left/right-only and --cherry-mark”
  1. Michael J GruberMar 7, 2011
  2. 1/9 revlist.c: introduce --left/right-only for unsymmetric pickingMichael J Gruber, Mar 7, 2011
  3. 2/9 t6007: Make sure we test --cherry-pickMichael J Gruber, Mar 7, 2011
  4. 3/9 rev-list: documentation and test for --left/right-onlyMichael J Gruber, Mar 7, 2011
  5. 4/9 rev-list: --left/right-only are mutually exclusiveMichael J Gruber, Mar 7, 2011
  6. 5/9 rev-list/log: factor out revision mark generationMichael J Gruber, Mar 7, 2011
  7. 6/9 revision.c: introduce --cherry-markMichael J Gruber, Mar 7, 2011
  8. Junio C HamanoMar 9, 2011
  9. 6/9 revision.c: introduce --cherry-markMichael J Gruber, Mar 10, 2011
  10. 7/9 rev-list: documentation and test for --cherry-markMichael J Gruber, Mar 7, 2011
  11. 8/9 log --cherry: a synonymMichael J Gruber, Mar 7, 2011
  12. 9/9 t6007: test rev-list --cherryMichael J Gruber, Mar 7, 2011
  13. Junio C HamanoMar 9, 2011
  14. Michael J GruberMar 10, 2011
  15. Junio C HamanoMar 10, 2011
  16. Michael J GruberMar 10, 2011
  17. 00/10 --left/right-only and --cherry-markMichael J Gruber, Mar 10, 2011
  18. 01/10 revlist.c: introduce --left/right-only for unsymmetric pickingMichael J Gruber, Mar 10, 2011
  19. 02/10 t6007: Make sure we test --cherry-pickMichael J Gruber, Mar 10, 2011
  20. 03/10 rev-list: documentation and test for --left/right-onlyMichael J Gruber, Mar 10, 2011
  21. 04/10 rev-list: --left/right-only are mutually exclusiveMichael J Gruber, Mar 10, 2011
  22. 05/10 rev-list/log: factor out revision mark generationMichael J Gruber, Mar 10, 2011
  23. 06/10 revision.c: introduce --cherry-markMichael J Gruber, Mar 10, 2011
  24. 07/10 rev-list: documentation and test for --cherry-markMichael J Gruber, Mar 10, 2011
  25. 08/10 log --cherry: a synonymMichael J Gruber, Mar 10, 2011
  26. 09/10 t6007: test rev-list --cherryMichael J Gruber, Mar 10, 2011
  27. 10/10 git-log: put space after commit markMichael J Gruber, Mar 10, 2011
  28. Junio C HamanoMar 10, 2011
  29. Michael J GruberMar 11, 2011
  30. Junio C HamanoMar 11, 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.