зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
1df2d656cc
Коммит
adbbb31e0d
21
revision.c
21
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_count = 0, right_count = 0;
|
||||||
int left_first;
|
int left_first;
|
||||||
struct patch_ids ids;
|
struct patch_ids ids;
|
||||||
|
unsigned cherry_flag;
|
||||||
|
|
||||||
/* First count the commits on the left and on the right */
|
/* First count the commits on the left and on the right */
|
||||||
for (p = list; p; p = p->next) {
|
for (p = list; p; p = p->next) {
|
||||||
|
@ -576,6 +577,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
|
||||||
commit->util = add_commit_patch_id(commit, &ids);
|
commit->util = add_commit_patch_id(commit, &ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* either cherry_mark or cherry_pick are true */
|
||||||
|
cherry_flag = revs->cherry_mark ? PATCHSAME : SHOWN;
|
||||||
|
|
||||||
/* Check the other side */
|
/* Check the other side */
|
||||||
for (p = list; p; p = p->next) {
|
for (p = list; p; p = p->next) {
|
||||||
struct commit *commit = p->item;
|
struct commit *commit = p->item;
|
||||||
|
@ -598,7 +602,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
|
||||||
if (!id)
|
if (!id)
|
||||||
continue;
|
continue;
|
||||||
id->seen = 1;
|
id->seen = 1;
|
||||||
commit->object.flags |= SHOWN;
|
commit->object.flags |= cherry_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now check the original side for seen ones */
|
/* 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)
|
||||||
if (!ent)
|
if (!ent)
|
||||||
continue;
|
continue;
|
||||||
if (ent->seen)
|
if (ent->seen)
|
||||||
commit->object.flags |= SHOWN;
|
commit->object.flags |= cherry_flag;
|
||||||
commit->util = NULL;
|
commit->util = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,7 +806,7 @@ static int limit_list(struct rev_info *revs)
|
||||||
show(revs, newlist);
|
show(revs, newlist);
|
||||||
show_early_output = NULL;
|
show_early_output = NULL;
|
||||||
}
|
}
|
||||||
if (revs->cherry_pick)
|
if (revs->cherry_pick || revs->cherry_mark)
|
||||||
cherry_pick_list(newlist, revs);
|
cherry_pick_list(newlist, revs);
|
||||||
|
|
||||||
if (revs->left_only || revs->right_only)
|
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
|
||||||
revs->right_only = 1;
|
revs->right_only = 1;
|
||||||
} else if (!strcmp(arg, "--count")) {
|
} else if (!strcmp(arg, "--count")) {
|
||||||
revs->count = 1;
|
revs->count = 1;
|
||||||
|
} else if (!strcmp(arg, "--cherry-mark")) {
|
||||||
|
if (revs->cherry_pick)
|
||||||
|
die("--cherry-mark is incompatible with --cherry-pick");
|
||||||
|
revs->cherry_mark = 1;
|
||||||
|
revs->limited = 1; /* needs limit_list() */
|
||||||
} else if (!strcmp(arg, "--cherry-pick")) {
|
} else if (!strcmp(arg, "--cherry-pick")) {
|
||||||
|
if (revs->cherry_mark)
|
||||||
|
die("--cherry-pick is incompatible with --cherry-mark");
|
||||||
revs->cherry_pick = 1;
|
revs->cherry_pick = 1;
|
||||||
revs->limited = 1;
|
revs->limited = 1;
|
||||||
} else if (!strcmp(arg, "--objects")) {
|
} else if (!strcmp(arg, "--objects")) {
|
||||||
|
@ -2270,6 +2281,8 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
|
||||||
return "-";
|
return "-";
|
||||||
else if (commit->object.flags & UNINTERESTING)
|
else if (commit->object.flags & UNINTERESTING)
|
||||||
return "^";
|
return "^";
|
||||||
|
else if (commit->object.flags & PATCHSAME)
|
||||||
|
return "=";
|
||||||
else if (!revs || revs->left_right) {
|
else if (!revs || revs->left_right) {
|
||||||
if (commit->object.flags & SYMMETRIC_LEFT)
|
if (commit->object.flags & SYMMETRIC_LEFT)
|
||||||
return "<";
|
return "<";
|
||||||
|
@ -2277,5 +2290,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
|
||||||
return ">";
|
return ">";
|
||||||
} else if (revs->graph)
|
} else if (revs->graph)
|
||||||
return "*";
|
return "*";
|
||||||
|
else if (revs->cherry_mark)
|
||||||
|
return "+";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#define CHILD_SHOWN (1u<<6)
|
#define CHILD_SHOWN (1u<<6)
|
||||||
#define ADDED (1u<<7) /* Parents already parsed and added? */
|
#define ADDED (1u<<7) /* Parents already parsed and added? */
|
||||||
#define SYMMETRIC_LEFT (1u<<8)
|
#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_SHORT_REFS 1
|
||||||
#define DECORATE_FULL_REFS 2
|
#define DECORATE_FULL_REFS 2
|
||||||
|
@ -68,6 +69,7 @@ struct rev_info {
|
||||||
reverse:1,
|
reverse:1,
|
||||||
reverse_output_stage:1,
|
reverse_output_stage:1,
|
||||||
cherry_pick:1,
|
cherry_pick:1,
|
||||||
|
cherry_mark:1,
|
||||||
bisect:1,
|
bisect:1,
|
||||||
ancestry_path:1,
|
ancestry_path:1,
|
||||||
first_parent_only:1;
|
first_parent_only:1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче