reflog: reduce scope of "struct rev_info"

Change the "cmd.stalefix" handling added in 1389d9ddaa (reflog expire
--fix-stale, 2007-01-06) to use a locally scoped "struct
rev_info". This code relies on mark_reachable_objects() twiddling
flags in the walked objects.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2021-12-22 05:06:46 +01:00 committed by Junio C Hamano
parent daf1d8285e
commit 994b328f36

View File

@ -28,7 +28,6 @@ static timestamp_t default_reflog_expire;
static timestamp_t default_reflog_expire_unreachable; static timestamp_t default_reflog_expire_unreachable;
struct cmd_reflog_expire_cb { struct cmd_reflog_expire_cb {
struct rev_info revs;
int stalefix; int stalefix;
timestamp_t expire_total; timestamp_t expire_total;
timestamp_t expire_unreachable; timestamp_t expire_unreachable;
@ -594,13 +593,15 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
* from reflog if the repository was pruned with older git. * from reflog if the repository was pruned with older git.
*/ */
if (cmd.stalefix) { if (cmd.stalefix) {
repo_init_revisions(the_repository, &cmd.revs, prefix); struct rev_info revs;
cmd.revs.do_not_die_on_missing_tree = 1;
cmd.revs.ignore_missing = 1; repo_init_revisions(the_repository, &revs, prefix);
cmd.revs.ignore_missing_links = 1; revs.do_not_die_on_missing_tree = 1;
revs.ignore_missing = 1;
revs.ignore_missing_links = 1;
if (flags & EXPIRE_REFLOGS_VERBOSE) if (flags & EXPIRE_REFLOGS_VERBOSE)
printf(_("Marking reachable objects...")); printf(_("Marking reachable objects..."));
mark_reachable_objects(&cmd.revs, 0, 0, NULL); mark_reachable_objects(&revs, 0, 0, NULL);
if (flags & EXPIRE_REFLOGS_VERBOSE) if (flags & EXPIRE_REFLOGS_VERBOSE)
putchar('\n'); putchar('\n');
} }