Skip to content

Commit a9a03fa

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6364739 commit a9a03fa

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

builtin/checkout.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,6 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
786786
{
787787
struct rev_info revs;
788788
struct object *object = &old->object;
789-
struct object_array refs;
790789

791790
init_revisions(&revs, NULL);
792791
setup_revisions(0, NULL, &revs, NULL);
@@ -797,14 +796,6 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
797796
for_each_ref(add_pending_uninteresting_ref, &revs);
798797
add_pending_oid(&revs, "HEAD", &new->object.oid, UNINTERESTING);
799798

800-
/* Save pending objects, so they can be cleaned up later. */
801-
refs = revs.pending;
802-
revs.leak_pending = 1;
803-
804-
/*
805-
* prepare_revision_walk (together with .leak_pending = 1) makes us
806-
* the sole owner of the list of pending objects.
807-
*/
808799
if (prepare_revision_walk(&revs))
809800
die(_("internal error in revision walk"));
810801
if (!(old->object.flags & UNINTERESTING))
@@ -813,9 +804,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
813804
describe_detached_head(_("Previous HEAD position was"), old);
814805

815806
/* Clean up objects used, as they will be reused. */
816-
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
817-
818-
object_array_clear(&refs);
807+
clear_commit_marks_all(ALL_REV_FLAGS);
819808
}
820809

821810
static int switch_branches(const struct checkout_opts *opts,

0 commit comments

Comments
 (0)