From: Junio C Hamano <gitster@pobox.com>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>,
git@vger.kernel.org
Subject: Re: [PATCH v2 2/2] files-backend: don't rewrite the `packed-refs` file unnecessarily
Date: Mon, 30 Oct 2017 13:52:44 +0900 [thread overview]
Message-ID: <xmqqzi895jab.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <6004e1dea6af33cb41c523855757aa6b04b912bc.1509181545.git.mhagger@alum.mit.edu> (Michael Haggerty's message of "Sat, 28 Oct 2017 11:16:02 +0200")
Michael Haggerty <mhagger@alum.mit.edu> writes:
> +int is_packed_transaction_needed(struct ref_store *ref_store,
> + struct ref_transaction *transaction)
> +{
> + struct packed_ref_store *refs = packed_downcast(
> + ref_store,
> + REF_STORE_READ,
> + "is_packed_transaction_needed");
> + struct strbuf referent = STRBUF_INIT;
> + size_t i;
> + int ret;
> +
> + if (!is_lock_file_locked(&refs->lock))
> + BUG("is_packed_transaction_needed() called while unlocked");
> +
> + /*
> + * We're only going to bother returning false for the common,
> + * trivial case that references are only being deleted, their
> + * old values are not being checked, and the old `packed-refs`
> + * file doesn't contain any of those reference(s). This gives
> + * false positives for some other cases that could
> + * theoretically be optimized away:
The way I understand "the old file does not contain these
references" part of the condition is "if there were any of these
refs, removing them from the loose ref storage may expose them,
which necessitates us to remove them from the packed-refs (and if
there is no loose ref for them, we do noeed to remove them from the
packed-refs)---so that definitely is not a no-op".
I was confused by the "is_noop?" version, especially about "do we
check the old value?" condition. The above does not help me all
that much to reach the same level of understanding as I have for the
other condition; sorry.
Is the reason why we know we want to play safe when the caller wants
to check the old value because that could cause the transaction to
abort if it does not match?
Thanks.
next prev parent reply other threads:[~2017-10-30 4:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-28 9:16 [PATCH v2 0/2] Avoid rewriting "packed-refs" unnecessarily Michael Haggerty
2017-10-28 9:16 ` [PATCH v2 1/2] t1409: check that `packed-refs` is not rewritten unnecessarily Michael Haggerty
2017-10-28 9:16 ` [PATCH v2 2/2] files-backend: don't rewrite the `packed-refs` file unnecessarily Michael Haggerty
2017-10-30 4:52 ` Junio C Hamano [this message]
2017-11-01 7:34 ` [PATCH v2 0/2] Avoid rewriting "packed-refs" unnecessarily Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqzi895jab.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).