git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin-symbolic-ref: comment on the use of "resolve_ref" with reading == 0

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2008, 10:08 UTC
Message-ID
<7vwshpsi1g.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080906095543.c627b692.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 11 quoted lines
> 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.
 (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".
So reading==0 is the logical thing to do here.
Previous: Christian CouderNext: Christian Couder
Message 2 of 4 in “builtin-symbolic-ref: comment on the use of "resolve_ref" with reading == 0”
  1. builtin-symbolic-ref: comment on the use of "resolve_ref" with reading == 0Christian Couder, Sep 6, 2008
  2. Junio C HamanoSep 6, 2008
  3. Christian CouderSep 6, 2008
  4. Junio C HamanoSep 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.