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

revision.c: 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Mar 7, 2011 at 13:31 UTC adbbb31e0d3b4cc7845c6d23d21c00da51025208
2 files changed +21 -4
revision.c
+18 -3
@@ -535,6 +535,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
535 int left_count = 0, right_count = 0;
536 int left_first;
537 struct patch_ids ids;
538 + unsigned cherry_flag;
539
540 /* First count the commits on the left and on the right */
541 for (p = list; p; p = p->next) {
@@ -576,6 +577,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
577 commit->util = add_commit_patch_id(commit, &ids);
578 }
579
580 + /* either cherry_mark or cherry_pick are true */
581 + cherry_flag = revs->cherry_mark ? PATCHSAME : SHOWN;
582 +
583 /* Check the other side */
584 for (p = list; p; p = p->next) {
585 struct commit *commit = p->item;
@@ -598,7 +602,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
602 if (!id)
603 continue;
604 id->seen = 1;
601 - commit->object.flags |= SHOWN;
605 + commit->object.flags |= cherry_flag;
606 }
607
608 /* Now check the original side for seen ones */
@@ -610,7 +614,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
614 if (!ent)
615 continue;
616 if (ent->seen)
613 - commit->object.flags |= SHOWN;
617 + commit->object.flags |= cherry_flag;
618 commit->util = NULL;
619 }
620
@@ -802,7 +806,7 @@ static int limit_list(struct rev_info *revs)
806 show(revs, newlist);
807 show_early_output = NULL;
808 }
805 - if (revs->cherry_pick)
809 + if (revs->cherry_pick || revs->cherry_mark)
810 cherry_pick_list(newlist, revs);
811
812 if (revs->left_only || revs->right_only)
@@ -1293,7 +1297,14 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1297 revs->right_only = 1;
1298 } else if (!strcmp(arg, "--count")) {
1299 revs->count = 1;
1300 + } else if (!strcmp(arg, "--cherry-mark")) {
1301 + if (revs->cherry_pick)
1302 + die("--cherry-mark is incompatible with --cherry-pick");
1303 + revs->cherry_mark = 1;
1304 + revs->limited = 1; /* needs limit_list() */
1305 } else if (!strcmp(arg, "--cherry-pick")) {
1306 + if (revs->cherry_mark)
1307 + die("--cherry-pick is incompatible with --cherry-mark");
1308 revs->cherry_pick = 1;
1309 revs->limited = 1;
1310 } else if (!strcmp(arg, "--objects")) {
@@ -2270,6 +2281,8 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
2281 return "-";
2282 else if (commit->object.flags & UNINTERESTING)
2283 return "^";
2284 + else if (commit->object.flags & PATCHSAME)
2285 + return "=";
2286 else if (!revs || revs->left_right) {
2287 if (commit->object.flags & SYMMETRIC_LEFT)
2288 return "<";
@@ -2277,5 +2290,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
2290 return ">";
2291 } else if (revs->graph)
2292 return "*";
2293 + else if (revs->cherry_mark)
2294 + return "+";
2295 return "";
2296 }
revision.h
+3 -1
@@ -14,7 +14,8 @@
14 #define CHILD_SHOWN (1u<<6)
15 #define ADDED (1u<<7) /* Parents already parsed and added? */
16 #define SYMMETRIC_LEFT (1u<<8)
17 -#define ALL_REV_FLAGS ((1u<<9)-1)
17 +#define PATCHSAME (1u<<9)
18 +#define ALL_REV_FLAGS ((1u<<10)-1)
19
20 #define DECORATE_SHORT_REFS 1
21 #define DECORATE_FULL_REFS 2
@@ -68,6 +69,7 @@ struct rev_info {
69 reverse:1,
70 reverse_output_stage:1,
71 cherry_pick:1,
72 + cherry_mark:1,
73 bisect:1,
74 ancestry_path:1,
75 first_parent_only:1;