Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-12-22 07:06:44 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-23 03:24:13 +0300
commit07815e2d97aa177780ea0d67069b5abd0524f936 (patch)
tree4b89f69f8a8c77235dc4358c267badd30ebb506d /builtin/reflog.c
parent20d6b6868c1446d548094a0a8aa4393a9c58447c (diff)
reflog expire: refactor & use "tip_commit" only for UE_NORMAL
Add an intermediate variable for "tip_commit" in reflog_expiry_prepare(), and only add it to the struct if we're handling the UE_NORMAL case. The code behaves the same way as before, but this makes the control flow clearer, and the shorter name allows us to fold a 4-line i/else into a one-line ternary instead. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/reflog.c')
-rw-r--r--builtin/reflog.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 8d05660e64..f18a63751f 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -354,16 +354,14 @@ static void reflog_expiry_prepare(const char *refname,
{
struct expire_reflog_policy_cb *cb = cb_data;
struct commit_list *elem;
+ struct commit *commit = NULL;
if (!cb->cmd.expire_unreachable || is_head(refname)) {
cb->unreachable_expire_kind = UE_HEAD;
} else {
- cb->tip_commit = lookup_commit_reference_gently(the_repository,
- oid, 1);
- if (!cb->tip_commit)
- cb->unreachable_expire_kind = UE_ALWAYS;
- else
- cb->unreachable_expire_kind = UE_NORMAL;
+ commit = lookup_commit_reference_gently(the_repository,
+ oid, 1);
+ cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;
}
if (cb->cmd.expire_unreachable <= cb->cmd.expire_total)
@@ -378,7 +376,9 @@ static void reflog_expiry_prepare(const char *refname,
commit_list_insert(elem->item, &cb->mark_list);
break;
case UE_NORMAL:
- commit_list_insert(cb->tip_commit, &cb->mark_list);
+ commit_list_insert(commit, &cb->mark_list);
+ /* For reflog_expiry_cleanup() below */
+ cb->tip_commit = commit;
}
cb->mark_limit = cb->cmd.expire_total;
mark_reachable(cb);