From: Jeff King <peff@peff.net>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] lock_ref_sha1_basic: handle REF_NODEREF with invalid refs
Date: Tue, 12 Jan 2016 04:52:57 -0500 [thread overview]
Message-ID: <20160112095257.GB9855@sigill.intra.peff.net> (raw)
In-Reply-To: <5694873D.5000001@alum.mit.edu>
On Tue, Jan 12, 2016 at 05:55:25AM +0100, Michael Haggerty wrote:
> On 01/11/2016 04:52 PM, Jeff King wrote:
> > We sometimes call lock_ref_sha1_basic both with REF_NODEREF
> > to operate directly on a symbolic ref.
>
> ^^^ This sentence seems to be missing some words.
I think it has one too many. :)
It was originally "both with a regular ref and with a symref", but I
shortened it since we only care about the symref case. I think just
getting rid of "both" is the right thing.
> > diff --git a/refs/files-backend.c b/refs/files-backend.c
> > index 180c837..ea67d82 100644
> > --- a/refs/files-backend.c
> > +++ b/refs/files-backend.c
> > @@ -1901,6 +1901,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
> >
> > refname = resolve_ref_unsafe(refname, resolve_flags,
> > lock->old_oid.hash, &type);
> > + if (!refname && (flags & REF_NODEREF))
> > + refname = resolve_ref_unsafe(orig_refname,
> > + resolve_flags | RESOLVE_REF_NO_RECURSE,
> > + lock->old_oid.hash, &type);
> > [...]
>
> The main risk for this change would be that this new recovery code
> allows the function to continue, but one of the outputs of the second
> function invocation is not correct for the code that follows. Let me
> think out loud:
>
> * refname -- now will be equal to orig_refname. I think the main effect
> is that it will be passed to verify_refname_available_dir(). This seems
> to be what we want.
>
> * type -- now reflects orig_refname; i.e., usually REF_ISSYMREF. This
> also seems correct.
>
> * lock->old_oid.hash -- is now ZEROS. This might get compared to the
> caller's old_sha1 in verify_lock(), and it will also be written to the
> reflog as the "old" value. I think this is also what we want.
>
> So this change looks good to me.
Thanks. I had a nagging feeling that I hadn't considered all cases, but
the way you've framed it makes sense to me.
-Peff
next prev parent reply other threads:[~2016-01-12 9:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 15:46 [PATCH 0/2] fix corner case with lock_ref_sha1_basic and REF_NODEREF Jeff King
2016-01-11 15:49 ` [PATCH 1/2] checkout,clone: check return value of create_symref Jeff King
2016-01-12 4:09 ` Michael Haggerty
2016-01-12 9:49 ` Jeff King
2016-01-11 15:52 ` [PATCH 2/2] lock_ref_sha1_basic: handle REF_NODEREF with invalid refs Jeff King
2016-01-11 18:28 ` Junio C Hamano
2016-01-12 4:55 ` Michael Haggerty
2016-01-12 9:52 ` Jeff King [this message]
2016-01-12 18:11 ` Junio C Hamano
2016-01-12 9:56 ` [PATCH v2 0/2] fix corner case with lock_ref_sha1_basic and REF_NODEREF Jeff King
2016-01-12 9:57 ` [PATCH v2 1/2] checkout,clone: check return value of create_symref Jeff King
2016-01-12 9:58 ` [PATCH v2 2/2] lock_ref_sha1_basic: handle REF_NODEREF with invalid refs Jeff King
2016-01-12 13:26 ` Jeff King
2016-01-12 13:55 ` [PATCH v3 " Jeff King
2016-01-12 19:41 ` Junio C Hamano
2016-01-12 20:22 ` Jeff King
2016-01-12 20:42 ` Jeff King
2016-01-12 21:43 ` [PATCH v4 0/3] fix corner cases with lock_ref_sha1_basic Jeff King
2016-01-12 21:44 ` [PATCH 1/3] checkout,clone: check return value of create_symref Jeff King
2016-01-12 21:44 ` [PATCH 2/3] lock_ref_sha1_basic: always fill old_oid while holding lock Jeff King
2016-01-13 1:25 ` Eric Sunshine
2016-01-13 11:38 ` Jeff King
2016-01-12 21:45 ` [PATCH 3/3] lock_ref_sha1_basic: handle REF_NODEREF with invalid refs 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160112095257.GB9855@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
/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).