commit: factor out clear_commit_marks_for_object_array
Factor out the code to clear the commit marks for a whole struct object_array from builtin/checkout.c into its own exported function clear_commit_marks_for_object_array and use it in bisect and bundle as well. It handles tags and commits and ignores objects of any other type. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
1062141928
commit
86a0a408b9
7
bisect.c
7
bisect.c
@ -818,7 +818,7 @@ static int check_ancestors(const char *prefix)
|
||||
{
|
||||
struct rev_info revs;
|
||||
struct object_array pending_copy;
|
||||
int i, res;
|
||||
int res;
|
||||
|
||||
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
|
||||
|
||||
@ -835,10 +835,7 @@ static int check_ancestors(const char *prefix)
|
||||
res = (revs.commits != NULL);
|
||||
|
||||
/* Clean up objects used, as they will be reused. */
|
||||
for (i = 0; i < pending_copy.nr; i++) {
|
||||
struct object *o = pending_copy.objects[i].item;
|
||||
clear_commit_marks((struct commit *)o, ALL_REV_FLAGS);
|
||||
}
|
||||
clear_commit_marks_for_object_array(&pending_copy, ALL_REV_FLAGS);
|
||||
free(pending_copy.objects);
|
||||
|
||||
return res;
|
||||
|
@ -663,7 +663,6 @@ static void orphaned_commit_warning(struct commit *commit)
|
||||
struct rev_info revs;
|
||||
struct object *object = &commit->object;
|
||||
struct object_array refs;
|
||||
unsigned int i;
|
||||
|
||||
init_revisions(&revs, NULL);
|
||||
setup_revisions(0, NULL, &revs, NULL);
|
||||
@ -683,12 +682,7 @@ static void orphaned_commit_warning(struct commit *commit)
|
||||
else
|
||||
describe_detached_head(_("Previous HEAD position was"), commit);
|
||||
|
||||
for (i = 0; i < refs.nr; i++) {
|
||||
struct object *o = refs.objects[i].item;
|
||||
struct commit *c = lookup_commit_reference_gently(o->sha1, 1);
|
||||
if (c)
|
||||
clear_commit_marks(c, ALL_REV_FLAGS);
|
||||
}
|
||||
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
|
||||
free(refs.objects);
|
||||
}
|
||||
|
||||
|
3
bundle.c
3
bundle.c
@ -141,8 +141,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
|
||||
refs.objects[i].name);
|
||||
}
|
||||
|
||||
for (i = 0; i < refs.nr; i++)
|
||||
clear_commit_marks((struct commit *)refs.objects[i].item, -1);
|
||||
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
|
||||
free(refs.objects);
|
||||
|
||||
if (verbose) {
|
||||
|
14
commit.c
14
commit.c
@ -440,6 +440,20 @@ void clear_commit_marks(struct commit *commit, unsigned int mark)
|
||||
}
|
||||
}
|
||||
|
||||
void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark)
|
||||
{
|
||||
struct object *object;
|
||||
struct commit *commit;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < a->nr; i++) {
|
||||
object = a->objects[i].item;
|
||||
commit = lookup_commit_reference_gently(object->sha1, 1);
|
||||
if (commit)
|
||||
clear_commit_marks(commit, mark);
|
||||
}
|
||||
}
|
||||
|
||||
struct commit *pop_commit(struct commit_list **stack)
|
||||
{
|
||||
struct commit_list *top = *stack;
|
||||
|
1
commit.h
1
commit.h
@ -126,6 +126,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
|
||||
struct commit *pop_commit(struct commit_list **stack);
|
||||
|
||||
void clear_commit_marks(struct commit *commit, unsigned int mark);
|
||||
void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark);
|
||||
|
||||
/*
|
||||
* Performs an in-place topological sort of list supplied.
|
||||
|
Loading…
Reference in New Issue
Block a user