From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 1/2] Clean up reflog unreachability pruning decision
Date: Tue, 31 Mar 2009 10:44:58 -0700 [thread overview]
Message-ID: <7vab7160yt.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.2.00.0903311003490.4093@localhost.localdomain> (Linus Torvalds's message of "Tue, 31 Mar 2009 10:09:55 -0700 (PDT)")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> From: Linus Torvalds <torvalds@linux-foundation.org>
> Date: Tue, 31 Mar 2009 09:45:22 -0700
>
> This clarifies the pruning rules for unreachable commits by having a
> separate helpder function for the unreachability decision.
>
> It's preparation for actual bigger changes to come to speed up the
> decision when the reachability calculations become a bottleneck.
>
> In the process it also _does_ change behavior, although in a way that I
> think is much saner than the old behavior (which was in my opinion not
> designed, just a result of how the tests were written). It now will prune
> reflog entries that are older than that 'prune_unreacable' time _and_ that
> have commit references that can't be even looked up.
> Of course, "--stale-fix" also does that, and does it regardless of the age
> of the reflog entry is, but I really think this is the right thing to do.
> If we can't even look it up, we should consider it to be unreachable.
>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> ---
> builtin-reflog.c | 32 ++++++++++++++++++++++++++------
> 1 files changed, 26 insertions(+), 6 deletions(-)
>
> Note the behavioural change. I think it's sane and "ObviouslyCorrect(tm)",
> but maybe somebody disagrees.
I did not recall initially when I was discussing this with you last night
but I think this "no commit? not prune" is intentional. The codepath is
not about logs/heads but logs/*anything*, and we allow pointers to non
commit objects (like v2.6.11-tree).
Also even if we limit ourselves to commits, @{-N} notation can be used to
see the history of branch switching, and that does not need any underlying
objects. I do not think it is interesting to be able to see which branch
you were on 30 days abo, though ;-)
> diff --git a/builtin-reflog.c b/builtin-reflog.c
> index d95f515..0355ce6 100644
> --- a/builtin-reflog.c
> +++ b/builtin-reflog.c
> @@ -209,6 +209,31 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
> return 1;
> }
>
> +static int unreachable(struct expire_reflog_cb *cb, struct commit *commit, unsigned char *sha1)
> +{
> + /*
> + * We may or may not have the commit yet - if not, look it
> + * up using the supplied sha1.
> + */
> + if (!commit) {
> + if (is_null_sha1(sha1))
> + return 0;
> +
> + commit = lookup_commit_reference_gently(sha1, 1);
> +
> + /* We can't even look it up - consider it unreachable */
> + if (!commit)
> + return 1;
/* If it is not a commit, keep it. */
if (!commit)
return 0;
> + }
> +
> + /* Reachable from the current reflog top? Don't prune */
That's "tip of the ref", not necessarily "reflog top".
> + if (in_merge_bases(commit, &cb->ref_commit, 1))
> + return 0;
> +
> + /* We can't reach it - prune it. */
> + return 1;
> +}
> +
> static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
> const char *email, unsigned long timestamp, int tz,
> const char *message, void *cb_data)
> @@ -230,12 +255,7 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
> if (timestamp < cb->cmd->expire_unreachable) {
> if (!cb->ref_commit)
> goto prune;
> - if (!old && !is_null_sha1(osha1))
> - old = lookup_commit_reference_gently(osha1, 1);
> - if (!new && !is_null_sha1(nsha1))
> - new = lookup_commit_reference_gently(nsha1, 1);
> - if ((old && !in_merge_bases(old, &cb->ref_commit, 1)) ||
> - (new && !in_merge_bases(new, &cb->ref_commit, 1)))
> + if (unreachable(cb, old, osha1) || unreachable(cb, new, nsha1))
> goto prune;
> }
>
> --
> 1.6.2.1.404.gb0085.dirty
prev parent reply other threads:[~2009-03-31 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-31 17:03 [PATCH 0/2] speed up reflog unreachability pruning Linus Torvalds
2009-03-31 17:09 ` [PATCH 1/2] Clean up reflog unreachability pruning decision Linus Torvalds
2009-03-31 17:11 ` [PATCH 2/2] Speed up reflog pruning of unreachable commits Linus Torvalds
2009-03-31 17:46 ` Junio C Hamano
2009-03-31 17:58 ` Linus Torvalds
2009-03-31 17:44 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vab7160yt.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).