diff options
author | René Scharfe <l.s.r@web.de> | 2017-12-25 18:47:04 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-12-28 22:50:05 +0100 |
commit | a9a03fa0d7292758b1c5038c0acb9466c9ac36da (patch) | |
tree | 50f979b0839ff97b3109d5b2d31b9f7617147c13 /builtin/checkout.c | |
parent | bundle: avoid using the rev_info flag leak_pending (diff) | |
download | git-a9a03fa0d7292758b1c5038c0acb9466c9ac36da.tar.xz git-a9a03fa0d7292758b1c5038c0acb9466c9ac36da.zip |
checkout: avoid using the rev_info flag leak_pending
The leak_pending flag is so awkward to use that multiple comments had to
be added around each occurrence. We only use it for remembering the
commits whose marks we have to clear after checking if the old HEAD is
detached. This is easy, though: We need to do that for the old commit,
the new one -- and for all refs.
Don't bother tracking exactly which commits need their flags cleared,
just nuke all we have in-core. This change is safe because refs can
point at anything, so other program parts can't depend on any kept flags
anyway. And since all refs are loaded we have to basically deal with
all commits anyway, so performance should not be negatively impacted.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index fc4f8fd2ea..4f61ff0aa0 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -786,7 +786,6 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new) { struct rev_info revs; struct object *object = &old->object; - struct object_array refs; init_revisions(&revs, NULL); setup_revisions(0, NULL, &revs, NULL); @@ -797,14 +796,6 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new) for_each_ref(add_pending_uninteresting_ref, &revs); add_pending_oid(&revs, "HEAD", &new->object.oid, UNINTERESTING); - /* Save pending objects, so they can be cleaned up later. */ - refs = revs.pending; - revs.leak_pending = 1; - - /* - * prepare_revision_walk (together with .leak_pending = 1) makes us - * the sole owner of the list of pending objects. - */ if (prepare_revision_walk(&revs)) die(_("internal error in revision walk")); if (!(old->object.flags & UNINTERESTING)) @@ -813,9 +804,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new) describe_detached_head(_("Previous HEAD position was"), old); /* Clean up objects used, as they will be reused. */ - clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS); - - object_array_clear(&refs); + clear_commit_marks_all(ALL_REV_FLAGS); } static int switch_branches(const struct checkout_opts *opts, |