rev-list: allow bisect and first-parent flags
Add first_parent_only parameter to find_bisection(), removing the barrier that prevented combining the --bisect and --first-parent flags when using git rev-list Based-on-patch-by: Tiago Botelho <tiagonbotelho@hotmail.com> Signed-off-by: Aaron Lipman <alipman88@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
15a4802a69
commit
0fe305a5d3
28
bisect.c
28
bisect.c
@ -88,15 +88,16 @@ static inline void weight_set(struct commit_list *elem, int weight)
|
||||
**commit_weight_at(&commit_weight, elem->item) = weight;
|
||||
}
|
||||
|
||||
static int count_interesting_parents(struct commit *commit)
|
||||
static int count_interesting_parents(struct commit *commit, int first_parent_only)
|
||||
{
|
||||
struct commit_list *p;
|
||||
int count;
|
||||
|
||||
for (count = 0, p = commit->parents; p; p = p->next) {
|
||||
if (p->item->object.flags & UNINTERESTING)
|
||||
continue;
|
||||
count++;
|
||||
if (!(p->item->object.flags & UNINTERESTING))
|
||||
count++;
|
||||
if (first_parent_only)
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@ -259,7 +260,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
|
||||
*/
|
||||
static struct commit_list *do_find_bisection(struct commit_list *list,
|
||||
int nr, int *weights,
|
||||
int find_all)
|
||||
int find_all, int first_parent_only)
|
||||
{
|
||||
int n, counted;
|
||||
struct commit_list *p;
|
||||
@ -271,7 +272,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
|
||||
unsigned flags = commit->object.flags;
|
||||
|
||||
*commit_weight_at(&commit_weight, p->item) = &weights[n++];
|
||||
switch (count_interesting_parents(commit)) {
|
||||
switch (count_interesting_parents(commit, first_parent_only)) {
|
||||
case 0:
|
||||
if (!(flags & TREESAME)) {
|
||||
weight_set(p, 1);
|
||||
@ -314,6 +315,8 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
|
||||
continue;
|
||||
if (weight(p) != -2)
|
||||
continue;
|
||||
if (first_parent_only)
|
||||
BUG("shouldn't be calling count-distance in fp mode");
|
||||
weight_set(p, count_distance(p));
|
||||
clear_distance(list);
|
||||
|
||||
@ -332,7 +335,10 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
|
||||
|
||||
if (0 <= weight(p))
|
||||
continue;
|
||||
for (q = p->item->parents; q; q = q->next) {
|
||||
|
||||
for (q = p->item->parents;
|
||||
q;
|
||||
q = first_parent_only ? NULL : q->next) {
|
||||
if (q->item->object.flags & UNINTERESTING)
|
||||
continue;
|
||||
if (0 <= weight(q))
|
||||
@ -370,7 +376,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
|
||||
}
|
||||
|
||||
void find_bisection(struct commit_list **commit_list, int *reaches,
|
||||
int *all, int find_all)
|
||||
int *all, int find_all, int first_parent_only)
|
||||
{
|
||||
int nr, on_list;
|
||||
struct commit_list *list, *p, *best, *next, *last;
|
||||
@ -406,7 +412,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
|
||||
weights = xcalloc(on_list, sizeof(*weights));
|
||||
|
||||
/* Do the real work of finding bisection commit. */
|
||||
best = do_find_bisection(list, nr, weights, find_all);
|
||||
best = do_find_bisection(list, nr, weights, find_all, first_parent_only);
|
||||
if (best) {
|
||||
if (!find_all) {
|
||||
list->item = best->item;
|
||||
@ -991,6 +997,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int
|
||||
enum bisect_error res = BISECT_OK;
|
||||
struct object_id *bisect_rev;
|
||||
char *steps_msg;
|
||||
int first_parent_only = 0; /* TODO: pass --first-parent flag from git bisect start */
|
||||
|
||||
read_bisect_terms(&term_bad, &term_good);
|
||||
if (read_bisect_refs())
|
||||
@ -1001,11 +1008,12 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int
|
||||
return res;
|
||||
|
||||
bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1);
|
||||
revs.first_parent_only = first_parent_only;
|
||||
revs.limited = 1;
|
||||
|
||||
bisect_common(&revs);
|
||||
|
||||
find_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr);
|
||||
find_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr, first_parent_only);
|
||||
revs.commits = managed_skipped(revs.commits, &tried);
|
||||
|
||||
if (!revs.commits) {
|
||||
|
||||
Reference in New Issue
Block a user