Merge branch 'jk/unleak-reflog-expire-entry'
Leakfix. * jk/unleak-reflog-expire-entry: reflog: close leak of reflog expire entrymaint
commit
a2384a76e7
|
|
@ -346,6 +346,7 @@ static int reflog_expire_condition(struct gc_config *cfg UNUSED)
|
||||||
count_reflog_entries, &data);
|
count_reflog_entries, &data);
|
||||||
|
|
||||||
reflog_expiry_cleanup(&data.policy);
|
reflog_expiry_cleanup(&data.policy);
|
||||||
|
reflog_clear_expire_config(&data.policy.opts);
|
||||||
return data.count >= data.limit;
|
return data.count >= data.limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,9 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
|
||||||
&cb);
|
&cb);
|
||||||
free(ref);
|
free(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reflog_clear_expire_config(&opts);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
14
reflog.c
14
reflog.c
|
|
@ -81,6 +81,20 @@ int reflog_expire_config(const char *var, const char *value,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reflog_clear_expire_config(struct reflog_expire_options *opts)
|
||||||
|
{
|
||||||
|
struct reflog_expire_entry_option *ent = opts->entries, *tmp;
|
||||||
|
|
||||||
|
while (ent) {
|
||||||
|
tmp = ent;
|
||||||
|
ent = ent->next;
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
opts->entries = NULL;
|
||||||
|
opts->entries_tail = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void reflog_expire_options_set_refname(struct reflog_expire_options *cb,
|
void reflog_expire_options_set_refname(struct reflog_expire_options *cb,
|
||||||
const char *ref)
|
const char *ref)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
2
reflog.h
2
reflog.h
|
|
@ -34,6 +34,8 @@ struct reflog_expire_options {
|
||||||
int reflog_expire_config(const char *var, const char *value,
|
int reflog_expire_config(const char *var, const char *value,
|
||||||
const struct config_context *ctx, void *cb);
|
const struct config_context *ctx, void *cb);
|
||||||
|
|
||||||
|
void reflog_clear_expire_config(struct reflog_expire_options *opts);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adapt the options so that they apply to the given refname. This applies any
|
* Adapt the options so that they apply to the given refname. This applies any
|
||||||
* per-reference reflog expiry configuration that may exist to the options.
|
* per-reference reflog expiry configuration that may exist to the options.
|
||||||
|
|
|
||||||
|
|
@ -673,4 +673,32 @@ test_expect_success 'reflog drop --all with reference' '
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'expire with pattern config' '
|
||||||
|
# Split refs/heads/ into two roots so we can apply config to each. Make
|
||||||
|
# two branches per root to verify that config is applied correctly
|
||||||
|
# multiple times.
|
||||||
|
git branch root1/branch1 &&
|
||||||
|
git branch root1/branch2 &&
|
||||||
|
git branch root2/branch1 &&
|
||||||
|
git branch root2/branch2 &&
|
||||||
|
|
||||||
|
test_config "gc.reflogexpire" "never" &&
|
||||||
|
test_config "gc.refs/heads/root2/*.reflogExpire" "now" &&
|
||||||
|
git reflog expire \
|
||||||
|
root1/branch1 root1/branch2 \
|
||||||
|
root2/branch1 root2/branch2 &&
|
||||||
|
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
root1/branch1@{0}
|
||||||
|
root1/branch2@{0}
|
||||||
|
EOF
|
||||||
|
git log -g --branches="root*" --format=%gD >actual.raw &&
|
||||||
|
# The sole reflog entry of each branch points to the same commit, so
|
||||||
|
# the order in which they are shown is nondeterministic. We just care
|
||||||
|
# about the what was expired (and what was not), so sort to get a known
|
||||||
|
# order.
|
||||||
|
sort <actual.raw >actual.sorted &&
|
||||||
|
test_cmp expect actual.sorted
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue