Merge branch 'ab/reflog-prep'

Code refactoring in the reflog part of refs API.

* ab/reflog-prep:
  reflog + refs-backend: move "verbose" out of the backend
  refs files-backend: assume cb->newlog if !EXPIRE_REFLOGS_DRY_RUN
  reflog: reduce scope of "struct rev_info"
  reflog expire: don't use lookup_commit_reference_gently()
  reflog expire: refactor & use "tip_commit" only for UE_NORMAL
  reflog expire: use "switch" over enum values
  reflog: change one->many worktree->refnames to use a string_list
  reflog expire: narrow scope of "cb" in cmd_reflog_expire()
  reflog delete: narrow scope of "cmd" passed to count_reflog_ent()
This commit is contained in:
Junio C Hamano 2022-01-10 11:52:52 -08:00
commit 626f2cabe6
3 changed files with 150 additions and 120 deletions

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;
@ -46,18 +45,12 @@ struct expire_reflog_policy_cb {
struct cmd_reflog_expire_cb cmd; struct cmd_reflog_expire_cb cmd;
struct commit *tip_commit; struct commit *tip_commit;
struct commit_list *tips; struct commit_list *tips;
unsigned int dry_run:1;
}; };
struct collected_reflog { struct worktree_reflogs {
struct object_id oid; struct worktree *worktree;
char reflog[FLEX_ARRAY]; struct string_list reflogs;
};
struct collect_reflog_cb {
struct collected_reflog **e;
int alloc;
int nr;
struct worktree *wt;
}; };
/* Remember to update object flag allocation in object.h */ /* Remember to update object flag allocation in object.h */
@ -310,10 +303,15 @@ static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *no
return 1; return 1;
if (timestamp < cb->cmd.expire_unreachable) { if (timestamp < cb->cmd.expire_unreachable) {
if (cb->unreachable_expire_kind == UE_ALWAYS) switch (cb->unreachable_expire_kind) {
return 1; case UE_ALWAYS:
if (unreachable(cb, old_commit, ooid) || unreachable(cb, new_commit, noid))
return 1; return 1;
case UE_NORMAL:
case UE_HEAD:
if (unreachable(cb, old_commit, ooid) || unreachable(cb, new_commit, noid))
return 1;
break;
}
} }
if (cb->cmd.recno && --(cb->cmd.recno) == 0) if (cb->cmd.recno && --(cb->cmd.recno) == 0)
@ -322,6 +320,28 @@ static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *no
return 0; return 0;
} }
static int should_expire_reflog_ent_verbose(struct object_id *ooid,
struct object_id *noid,
const char *email,
timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
struct expire_reflog_policy_cb *cb = cb_data;
int expire;
expire = should_expire_reflog_ent(ooid, noid, email, timestamp, tz,
message, cb);
if (!expire)
printf("keep %s", message);
else if (cb->dry_run)
printf("would prune %s", message);
else
printf("prune %s", message);
return expire;
}
static int push_tip_to_list(const char *refname, const struct object_id *oid, static int push_tip_to_list(const char *refname, const struct object_id *oid,
int flags, void *cb_data) int flags, void *cb_data)
{ {
@ -355,75 +375,71 @@ static void reflog_expiry_prepare(const char *refname,
void *cb_data) void *cb_data)
{ {
struct expire_reflog_policy_cb *cb = cb_data; struct expire_reflog_policy_cb *cb = cb_data;
struct commit_list *elem;
struct commit *commit = NULL;
if (!cb->cmd.expire_unreachable || is_head(refname)) { if (!cb->cmd.expire_unreachable || is_head(refname)) {
cb->tip_commit = NULL;
cb->unreachable_expire_kind = UE_HEAD; cb->unreachable_expire_kind = UE_HEAD;
} else { } else {
cb->tip_commit = lookup_commit_reference_gently(the_repository, commit = lookup_commit(the_repository, oid);
oid, 1); cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;
if (!cb->tip_commit)
cb->unreachable_expire_kind = UE_ALWAYS;
else
cb->unreachable_expire_kind = UE_NORMAL;
} }
if (cb->cmd.expire_unreachable <= cb->cmd.expire_total) if (cb->cmd.expire_unreachable <= cb->cmd.expire_total)
cb->unreachable_expire_kind = UE_ALWAYS; cb->unreachable_expire_kind = UE_ALWAYS;
cb->mark_list = NULL; switch (cb->unreachable_expire_kind) {
cb->tips = NULL; case UE_ALWAYS:
if (cb->unreachable_expire_kind != UE_ALWAYS) { return;
if (cb->unreachable_expire_kind == UE_HEAD) { case UE_HEAD:
struct commit_list *elem; for_each_ref(push_tip_to_list, &cb->tips);
for (elem = cb->tips; elem; elem = elem->next)
for_each_ref(push_tip_to_list, &cb->tips); commit_list_insert(elem->item, &cb->mark_list);
for (elem = cb->tips; elem; elem = elem->next) break;
commit_list_insert(elem->item, &cb->mark_list); case UE_NORMAL:
} else { commit_list_insert(commit, &cb->mark_list);
commit_list_insert(cb->tip_commit, &cb->mark_list); /* For reflog_expiry_cleanup() below */
} cb->tip_commit = commit;
cb->mark_limit = cb->cmd.expire_total;
mark_reachable(cb);
} }
cb->mark_limit = cb->cmd.expire_total;
mark_reachable(cb);
} }
static void reflog_expiry_cleanup(void *cb_data) static void reflog_expiry_cleanup(void *cb_data)
{ {
struct expire_reflog_policy_cb *cb = cb_data; struct expire_reflog_policy_cb *cb = cb_data;
struct commit_list *elem;
if (cb->unreachable_expire_kind != UE_ALWAYS) { switch (cb->unreachable_expire_kind) {
if (cb->unreachable_expire_kind == UE_HEAD) { case UE_ALWAYS:
struct commit_list *elem; return;
for (elem = cb->tips; elem; elem = elem->next) case UE_HEAD:
clear_commit_marks(elem->item, REACHABLE); for (elem = cb->tips; elem; elem = elem->next)
free_commit_list(cb->tips); clear_commit_marks(elem->item, REACHABLE);
} else { free_commit_list(cb->tips);
clear_commit_marks(cb->tip_commit, REACHABLE); break;
} case UE_NORMAL:
clear_commit_marks(cb->tip_commit, REACHABLE);
break;
} }
} }
static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data) static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
{ {
struct collected_reflog *e; struct worktree_reflogs *cb = cb_data;
struct collect_reflog_cb *cb = cb_data; struct worktree *worktree = cb->worktree;
struct strbuf newref = STRBUF_INIT; struct strbuf newref = STRBUF_INIT;
/* /*
* Avoid collecting the same shared ref multiple times because * Avoid collecting the same shared ref multiple times because
* they are available via all worktrees. * they are available via all worktrees.
*/ */
if (!cb->wt->is_current && ref_type(ref) == REF_TYPE_NORMAL) if (!worktree->is_current && ref_type(ref) == REF_TYPE_NORMAL)
return 0; return 0;
strbuf_worktree_ref(cb->wt, &newref, ref); strbuf_worktree_ref(worktree, &newref, ref);
FLEX_ALLOC_STR(e, reflog, newref.buf); string_list_append_nodup(&cb->reflogs, strbuf_detach(&newref, NULL));
strbuf_release(&newref);
oidcpy(&e->oid, oid);
ALLOC_GROW(cb->e, cb->nr + 1, cb->alloc);
cb->e[cb->nr++] = e;
return 0; return 0;
} }
@ -541,11 +557,13 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
{ {
struct expire_reflog_policy_cb cb; struct cmd_reflog_expire_cb cmd = { 0 };
timestamp_t now = time(NULL); timestamp_t now = time(NULL);
int i, status, do_all, all_worktrees = 1; int i, status, do_all, all_worktrees = 1;
int explicit_expiry = 0; int explicit_expiry = 0;
unsigned int flags = 0; unsigned int flags = 0;
int verbose = 0;
reflog_expiry_should_prune_fn *should_prune_fn = should_expire_reflog_ent;
default_reflog_expire_unreachable = now - 30 * 24 * 3600; default_reflog_expire_unreachable = now - 30 * 24 * 3600;
default_reflog_expire = now - 90 * 24 * 3600; default_reflog_expire = now - 90 * 24 * 3600;
@ -553,10 +571,9 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
save_commit_buffer = 0; save_commit_buffer = 0;
do_all = status = 0; do_all = status = 0;
memset(&cb, 0, sizeof(cb));
cb.cmd.expire_total = default_reflog_expire; cmd.expire_total = default_reflog_expire;
cb.cmd.expire_unreachable = default_reflog_expire_unreachable; cmd.expire_unreachable = default_reflog_expire_unreachable;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
const char *arg = argv[i]; const char *arg = argv[i];
@ -564,17 +581,17 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n")) if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
flags |= EXPIRE_REFLOGS_DRY_RUN; flags |= EXPIRE_REFLOGS_DRY_RUN;
else if (skip_prefix(arg, "--expire=", &arg)) { else if (skip_prefix(arg, "--expire=", &arg)) {
if (parse_expiry_date(arg, &cb.cmd.expire_total)) if (parse_expiry_date(arg, &cmd.expire_total))
die(_("'%s' is not a valid timestamp"), arg); die(_("'%s' is not a valid timestamp"), arg);
explicit_expiry |= EXPIRE_TOTAL; explicit_expiry |= EXPIRE_TOTAL;
} }
else if (skip_prefix(arg, "--expire-unreachable=", &arg)) { else if (skip_prefix(arg, "--expire-unreachable=", &arg)) {
if (parse_expiry_date(arg, &cb.cmd.expire_unreachable)) if (parse_expiry_date(arg, &cmd.expire_unreachable))
die(_("'%s' is not a valid timestamp"), arg); die(_("'%s' is not a valid timestamp"), arg);
explicit_expiry |= EXPIRE_UNREACH; explicit_expiry |= EXPIRE_UNREACH;
} }
else if (!strcmp(arg, "--stale-fix")) else if (!strcmp(arg, "--stale-fix"))
cb.cmd.stalefix = 1; cmd.stalefix = 1;
else if (!strcmp(arg, "--rewrite")) else if (!strcmp(arg, "--rewrite"))
flags |= EXPIRE_REFLOGS_REWRITE; flags |= EXPIRE_REFLOGS_REWRITE;
else if (!strcmp(arg, "--updateref")) else if (!strcmp(arg, "--updateref"))
@ -584,7 +601,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
else if (!strcmp(arg, "--single-worktree")) else if (!strcmp(arg, "--single-worktree"))
all_worktrees = 0; all_worktrees = 0;
else if (!strcmp(arg, "--verbose")) else if (!strcmp(arg, "--verbose"))
flags |= EXPIRE_REFLOGS_VERBOSE; verbose = 1;
else if (!strcmp(arg, "--")) { else if (!strcmp(arg, "--")) {
i++; i++;
break; break;
@ -595,54 +612,65 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
break; break;
} }
if (verbose)
should_prune_fn = should_expire_reflog_ent_verbose;
/* /*
* We can trust the commits and objects reachable from refs * We can trust the commits and objects reachable from refs
* even in older repository. We cannot trust what's reachable * even in older repository. We cannot trust what's reachable
* from reflog if the repository was pruned with older git. * from reflog if the repository was pruned with older git.
*/ */
if (cb.cmd.stalefix) { if (cmd.stalefix) {
repo_init_revisions(the_repository, &cb.cmd.revs, prefix); struct rev_info revs;
cb.cmd.revs.do_not_die_on_missing_tree = 1;
cb.cmd.revs.ignore_missing = 1; repo_init_revisions(the_repository, &revs, prefix);
cb.cmd.revs.ignore_missing_links = 1; revs.do_not_die_on_missing_tree = 1;
if (flags & EXPIRE_REFLOGS_VERBOSE) revs.ignore_missing = 1;
revs.ignore_missing_links = 1;
if (verbose)
printf(_("Marking reachable objects...")); printf(_("Marking reachable objects..."));
mark_reachable_objects(&cb.cmd.revs, 0, 0, NULL); mark_reachable_objects(&revs, 0, 0, NULL);
if (flags & EXPIRE_REFLOGS_VERBOSE) if (verbose)
putchar('\n'); putchar('\n');
} }
if (do_all) { if (do_all) {
struct collect_reflog_cb collected; struct worktree_reflogs collected = {
.reflogs = STRING_LIST_INIT_DUP,
};
struct string_list_item *item;
struct worktree **worktrees, **p; struct worktree **worktrees, **p;
int i;
memset(&collected, 0, sizeof(collected));
worktrees = get_worktrees(); worktrees = get_worktrees();
for (p = worktrees; *p; p++) { for (p = worktrees; *p; p++) {
if (!all_worktrees && !(*p)->is_current) if (!all_worktrees && !(*p)->is_current)
continue; continue;
collected.wt = *p; collected.worktree = *p;
refs_for_each_reflog(get_worktree_ref_store(*p), refs_for_each_reflog(get_worktree_ref_store(*p),
collect_reflog, &collected); collect_reflog, &collected);
} }
free_worktrees(worktrees); free_worktrees(worktrees);
for (i = 0; i < collected.nr; i++) {
struct collected_reflog *e = collected.e[i];
set_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog); for_each_string_list_item(item, &collected.reflogs) {
status |= reflog_expire(e->reflog, flags, struct expire_reflog_policy_cb cb = {
.cmd = cmd,
.dry_run = !!(flags & EXPIRE_REFLOGS_DRY_RUN),
};
set_reflog_expiry_param(&cb.cmd, explicit_expiry, item->string);
status |= reflog_expire(item->string, flags,
reflog_expiry_prepare, reflog_expiry_prepare,
should_expire_reflog_ent, should_prune_fn,
reflog_expiry_cleanup, reflog_expiry_cleanup,
&cb); &cb);
free(e);
} }
free(collected.e); string_list_clear(&collected.reflogs, 0);
} }
for (; i < argc; i++) { for (; i < argc; i++) {
char *ref; char *ref;
struct expire_reflog_policy_cb cb = { .cmd = cmd };
if (!dwim_log(argv[i], strlen(argv[i]), NULL, &ref)) { if (!dwim_log(argv[i], strlen(argv[i]), NULL, &ref)) {
status |= error(_("%s points nowhere!"), argv[i]); status |= error(_("%s points nowhere!"), argv[i]);
continue; continue;
@ -650,7 +678,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref); set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);
status |= reflog_expire(ref, flags, status |= reflog_expire(ref, flags,
reflog_expiry_prepare, reflog_expiry_prepare,
should_expire_reflog_ent, should_prune_fn,
reflog_expiry_cleanup, reflog_expiry_cleanup,
&cb); &cb);
free(ref); free(ref);
@ -662,19 +690,19 @@ static int count_reflog_ent(struct object_id *ooid, struct object_id *noid,
const char *email, timestamp_t timestamp, int tz, const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data) const char *message, void *cb_data)
{ {
struct expire_reflog_policy_cb *cb = cb_data; struct cmd_reflog_expire_cb *cb = cb_data;
if (!cb->cmd.expire_total || timestamp < cb->cmd.expire_total) if (!cb->expire_total || timestamp < cb->expire_total)
cb->cmd.recno++; cb->recno++;
return 0; return 0;
} }
static int cmd_reflog_delete(int argc, const char **argv, const char *prefix) static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
{ {
struct expire_reflog_policy_cb cb; struct cmd_reflog_expire_cb cmd = { 0 };
int i, status = 0; int i, status = 0;
unsigned int flags = 0; unsigned int flags = 0;
int verbose = 0;
memset(&cb, 0, sizeof(cb)); reflog_expiry_should_prune_fn *should_prune_fn = should_expire_reflog_ent;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
const char *arg = argv[i]; const char *arg = argv[i];
@ -685,7 +713,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
else if (!strcmp(arg, "--updateref")) else if (!strcmp(arg, "--updateref"))
flags |= EXPIRE_REFLOGS_UPDATE_REF; flags |= EXPIRE_REFLOGS_UPDATE_REF;
else if (!strcmp(arg, "--verbose")) else if (!strcmp(arg, "--verbose"))
flags |= EXPIRE_REFLOGS_VERBOSE; verbose = 1;
else if (!strcmp(arg, "--")) { else if (!strcmp(arg, "--")) {
i++; i++;
break; break;
@ -696,6 +724,9 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
break; break;
} }
if (verbose)
should_prune_fn = should_expire_reflog_ent_verbose;
if (argc - i < 1) if (argc - i < 1)
return error(_("no reflog specified to delete")); return error(_("no reflog specified to delete"));
@ -703,6 +734,9 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
const char *spec = strstr(argv[i], "@{"); const char *spec = strstr(argv[i], "@{");
char *ep, *ref; char *ep, *ref;
int recno; int recno;
struct expire_reflog_policy_cb cb = {
.dry_run = !!(flags & EXPIRE_REFLOGS_DRY_RUN),
};
if (!spec) { if (!spec) {
status |= error(_("not a reflog: %s"), argv[i]); status |= error(_("not a reflog: %s"), argv[i]);
@ -716,17 +750,18 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
recno = strtoul(spec + 2, &ep, 10); recno = strtoul(spec + 2, &ep, 10);
if (*ep == '}') { if (*ep == '}') {
cb.cmd.recno = -recno; cmd.recno = -recno;
for_each_reflog_ent(ref, count_reflog_ent, &cb); for_each_reflog_ent(ref, count_reflog_ent, &cmd);
} else { } else {
cb.cmd.expire_total = approxidate(spec + 2); cmd.expire_total = approxidate(spec + 2);
for_each_reflog_ent(ref, count_reflog_ent, &cb); for_each_reflog_ent(ref, count_reflog_ent, &cmd);
cb.cmd.expire_total = 0; cmd.expire_total = 0;
} }
cb.cmd = cmd;
status |= reflog_expire(ref, flags, status |= reflog_expire(ref, flags,
reflog_expiry_prepare, reflog_expiry_prepare,
should_expire_reflog_ent, should_prune_fn,
reflog_expiry_cleanup, reflog_expiry_cleanup,
&cb); &cb);
free(ref); free(ref);

3
refs.h
View file

@ -820,8 +820,7 @@ enum ref_type ref_type(const char *refname);
enum expire_reflog_flags { enum expire_reflog_flags {
EXPIRE_REFLOGS_DRY_RUN = 1 << 0, EXPIRE_REFLOGS_DRY_RUN = 1 << 0,
EXPIRE_REFLOGS_UPDATE_REF = 1 << 1, EXPIRE_REFLOGS_UPDATE_REF = 1 << 1,
EXPIRE_REFLOGS_VERBOSE = 1 << 2, EXPIRE_REFLOGS_REWRITE = 1 << 2,
EXPIRE_REFLOGS_REWRITE = 1 << 3
}; };
/* /*

View file

@ -3082,11 +3082,12 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
} }
struct expire_reflog_cb { struct expire_reflog_cb {
unsigned int flags;
reflog_expiry_should_prune_fn *should_prune_fn; reflog_expiry_should_prune_fn *should_prune_fn;
void *policy_cb; void *policy_cb;
FILE *newlog; FILE *newlog;
struct object_id last_kept_oid; struct object_id last_kept_oid;
unsigned int rewrite:1,
dry_run:1;
}; };
static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid, static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
@ -3094,33 +3095,27 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
const char *message, void *cb_data) const char *message, void *cb_data)
{ {
struct expire_reflog_cb *cb = cb_data; struct expire_reflog_cb *cb = cb_data;
struct expire_reflog_policy_cb *policy_cb = cb->policy_cb; reflog_expiry_should_prune_fn *fn = cb->should_prune_fn;
if (cb->flags & EXPIRE_REFLOGS_REWRITE) if (cb->rewrite)
ooid = &cb->last_kept_oid; ooid = &cb->last_kept_oid;
if ((*cb->should_prune_fn)(ooid, noid, email, timestamp, tz, if (fn(ooid, noid, email, timestamp, tz, message, cb->policy_cb))
message, policy_cb)) { return 0;
if (!cb->newlog)
printf("would prune %s", message); if (cb->dry_run)
else if (cb->flags & EXPIRE_REFLOGS_VERBOSE) return 0; /* --dry-run */
printf("prune %s", message);
} else { fprintf(cb->newlog, "%s %s %s %"PRItime" %+05d\t%s", oid_to_hex(ooid),
if (cb->newlog) { oid_to_hex(noid), email, timestamp, tz, message);
fprintf(cb->newlog, "%s %s %s %"PRItime" %+05d\t%s", oidcpy(&cb->last_kept_oid, noid);
oid_to_hex(ooid), oid_to_hex(noid),
email, timestamp, tz, message);
oidcpy(&cb->last_kept_oid, noid);
}
if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
printf("keep %s", message);
}
return 0; return 0;
} }
static int files_reflog_expire(struct ref_store *ref_store, static int files_reflog_expire(struct ref_store *ref_store,
const char *refname, const char *refname,
unsigned int flags, unsigned int expire_flags,
reflog_expiry_prepare_fn prepare_fn, reflog_expiry_prepare_fn prepare_fn,
reflog_expiry_should_prune_fn should_prune_fn, reflog_expiry_should_prune_fn should_prune_fn,
reflog_expiry_cleanup_fn cleanup_fn, reflog_expiry_cleanup_fn cleanup_fn,
@ -3138,7 +3133,8 @@ static int files_reflog_expire(struct ref_store *ref_store,
const struct object_id *oid; const struct object_id *oid;
memset(&cb, 0, sizeof(cb)); memset(&cb, 0, sizeof(cb));
cb.flags = flags; cb.rewrite = !!(expire_flags & EXPIRE_REFLOGS_REWRITE);
cb.dry_run = !!(expire_flags & EXPIRE_REFLOGS_DRY_RUN);
cb.policy_cb = policy_cb_data; cb.policy_cb = policy_cb_data;
cb.should_prune_fn = should_prune_fn; cb.should_prune_fn = should_prune_fn;
@ -3174,7 +3170,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
files_reflog_path(refs, &log_file_sb, refname); files_reflog_path(refs, &log_file_sb, refname);
log_file = strbuf_detach(&log_file_sb, NULL); log_file = strbuf_detach(&log_file_sb, NULL);
if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) { if (!cb.dry_run) {
/* /*
* Even though holding $GIT_DIR/logs/$reflog.lock has * Even though holding $GIT_DIR/logs/$reflog.lock has
* no locking implications, we use the lock_file * no locking implications, we use the lock_file
@ -3201,7 +3197,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb); refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb);
(*cleanup_fn)(cb.policy_cb); (*cleanup_fn)(cb.policy_cb);
if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) { if (!cb.dry_run) {
/* /*
* It doesn't make sense to adjust a reference pointed * It doesn't make sense to adjust a reference pointed
* to by a symbolic ref based on expiring entries in * to by a symbolic ref based on expiring entries in
@ -3211,7 +3207,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
*/ */
int update = 0; int update = 0;
if ((flags & EXPIRE_REFLOGS_UPDATE_REF) && if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
!is_null_oid(&cb.last_kept_oid)) { !is_null_oid(&cb.last_kept_oid)) {
int ignore_errno; int ignore_errno;
int type; int type;