aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2011-10-01 18:09:36 +0200
committerJunio C Hamano <gitster@pobox.com>2011-10-03 11:15:32 -0700
commit1062141928aaa1d272be8ce007d371168e8daef6 (patch)
treeffdfe54831539ce4218798c22e1b6d621f32857f
parent5be7859962585589f374f8467f3252bfcfa10fd0 (diff)
downloadgit-1062141928aaa1d272be8ce007d371168e8daef6.tar.gz
git-1062141928aaa1d272be8ce007d371168e8daef6.tar.xz
checkout: use leak_pending flag
Instead of going through all the references again when we clear the commit marks, do it like bisect and bundle and gain ownership of the list of pending objects which we constructed from those references. We simply copy the struct object_array that points to the list, set the flag leak_pending and then prepare_revision_walk won't destroy it and it's ours. We use it to clear the marks and free it at the end. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/checkout.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a76899d73..2e8402fe0 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -596,17 +596,6 @@ static int add_pending_uninteresting_ref(const char *refname,
return 0;
}
-static int clear_commit_marks_from_one_ref(const char *refname,
- const unsigned char *sha1,
- int flags,
- void *cb_data)
-{
- struct commit *commit = lookup_commit_reference_gently(sha1, 1);
- if (commit)
- clear_commit_marks(commit, -1);
- return 0;
-}
-
static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
parse_commit(commit);
@@ -673,6 +662,8 @@ 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);
@@ -682,6 +673,9 @@ static void orphaned_commit_warning(struct commit *commit)
for_each_ref(add_pending_uninteresting_ref, &revs);
+ refs = revs.pending;
+ revs.leak_pending = 1;
+
if (prepare_revision_walk(&revs))
die(_("internal error in revision walk"));
if (!(commit->object.flags & UNINTERESTING))
@@ -689,8 +683,13 @@ static void orphaned_commit_warning(struct commit *commit)
else
describe_detached_head(_("Previous HEAD position was"), commit);
- clear_commit_marks(commit, -1);
- for_each_ref(clear_commit_marks_from_one_ref, NULL);
+ 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);
+ }
+ free(refs.objects);
}
static int switch_branches(struct checkout_opts *opts, struct branch_info *new)