From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] builtin-symbolic-ref: comment on the use of "resolve_ref" with reading == 0
Date: Sat, 6 Sep 2008 14:03:13 +0200 [thread overview]
Message-ID: <200809061403.14592.chriscool@tuxfamily.org> (raw)
In-Reply-To: <7vwshpsi1g.fsf@gitster.siamese.dyndns.org>
Le samedi 6 septembre 2008, Junio C Hamano a écrit :
> Christian Couder <chriscool@tuxfamily.org> writes:
> > diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
> > index bfc78bb..9490c47 100644
> > --- a/builtin-symbolic-ref.c
> > +++ b/builtin-symbolic-ref.c
> > @@ -12,6 +12,16 @@ static void check_symref(const char *HEAD, int
> > quiet) ...
> > + /*
> > + * It doesn't seem logical to use "resolve_ref" with reading == 0
> > + * as we are just checking if a ref exists,...
> > ...
> > + */
>
> I have to say that this comment is confused.
>
> When you have a full ref (as opposed to an abbreviated one that you might
> give to dwim_ref()), you can use it for two kinds of things:
>
> (1) You can use it to find out what _object_ the ref points at. This is
> "reading" the ref, and the ref, if it is not symbolic, has to exist,
> and if it is symbolic, it has to point at an existing ref, because
> the "read" goes through the symref to the ref it points at.
Then the parameter should perhaps be
called "get_object", "get_target", "full_dereference" or something like
that instead of "reading".
> (2) Anything else. This could be a prelude to "writing" to the ref, in
> which case a write to a symref that points at yet-to-be-born ref
> will create the real ref pointed by the symref, so such a symref is
> not an error. It has to answer "here is the real ref you should write
> into" (or, "we will write into").
>
> But the access that is not "reading" does not have to be "writing";
> it can be merely checking _where it leads to_. And check_symref()
> uses this call for exactly that purpose. This access is not
> "checking if a ref exists".
In "resolve_ref" in refs.c there is the following comment:
/* Special case: non-existing file.
* Not having the refs/heads/new-branch is OK
* if we are writing into it, so is .git/HEAD
* that points at refs/heads/master still to be
* born. It is NOT OK if we are resolving for
* reading.
*/
that seems to mean that we are either "writing" or "reading".
> So reading==0 is the logical thing to do here.
It seems logical after your explanations, yes, and thank you for them, but I
don't think it is logical when reading the existing source code or
comments.
Regards,
Christian.
next prev parent reply other threads:[~2008-09-06 12:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-06 7:55 [PATCH] builtin-symbolic-ref: comment on the use of "resolve_ref" with reading == 0 Christian Couder
2008-09-06 10:08 ` Junio C Hamano
2008-09-06 12:03 ` Christian Couder [this message]
2008-09-08 0:33 ` Junio C Hamano
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=200809061403.14592.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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).