summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1062141)
raw | patch | inline | side by side (parent: 1062141)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 1 Oct 2011 16:16:08 +0000 (18:16 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 3 Oct 2011 18:15:34 +0000 (11:15 -0700) |
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>
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>
bisect.c | patch | blob | history | |
builtin/checkout.c | patch | blob | history | |
bundle.c | patch | blob | history | |
commit.c | patch | blob | history | |
commit.h | patch | blob | history |
diff --git a/bisect.c b/bisect.c
index 63cf166a6a7c03f785d34c135d04f1480ef4a000..54674fc2487093845486e8ce60ec8eda804bbb90 100644 (file)
--- a/bisect.c
+++ b/bisect.c
{
struct rev_info revs;
struct object_array pending_copy;
- int i, res;
+ int res;
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
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;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2e8402fe041b6556e3bd581e43b643fa02036011..cefa51d515c0b472ed94328f587fcec1aaa5f3ad 100644 (file)
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
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);
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);
}
diff --git a/bundle.c b/bundle.c
index 26cc9ab50732ff96e4a94f81c563d9bd589fe2b6..a8ea918c08c92077a532185480d8693fa21bc4dc 100644 (file)
--- a/bundle.c
+++ b/bundle.c
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) {
diff --git a/commit.c b/commit.c
index ac337c7d7dc1724fa918f9340816d3102edb10bd..4d80f2522c084c80ee7e75831cdd3d52e111f1ae 100644 (file)
--- a/commit.c
+++ b/commit.c
}
}
+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;
diff --git a/commit.h b/commit.h
index a2d571b97410fa857b4c177325c4556dac50fe3f..641f70fb1ee271258e992c04eb33501fa91bcf3f 100644 (file)
--- a/commit.h
+++ b/commit.h
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.