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

Re: [PATCH 2/2] gitweb: Make git_get_refs_list do work of git_get_references

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 20, 2006, 22:40 UTC
Message-ID
<200609210040.52886.jnareb@gmail.com>
In-Reply-To
<7veju6h0et.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 24 quoted lines
> Jakub Narebski wrote:
>> +                     if (! $4) { # unpeeled, direct reference
>> +                             push @refs, { hash => $1, name => $3 }; # without type
>> +                     } elsif ($3 eq $refs[-1]{'name'}) {
>> +                             # most likely a tag is followed by its peeled
>> +                             # (deref) one, and when that happens we know the
>> +                             # previous one was of type 'tag'.
>> +                             $refs[-1]{'type'} = "tag";
>> +                     }
>>...
>> -     return \@reflist;
>> +     return (\@reflist, \%refs);
> 
> You are maintaining reflist (an array of hashrefs each element
> of which describes name, type, hash and other parse_ref()
> information for the ref) and refs (a hash that maps from name to
> hash) separatly.  I wonder if this really has the performance
> advantage over just compute and return reflist from here and
> have the callers who need the mapping to derive it from the list
> (i.e.
> 
>         my ($reflist) = git_get_refs_list();
>         my %refs = map { $_->{name} => $_->{hash} } @$reflist;
> ).

The %refs hash contain also map from peeled (dereferenced) object to ref name. The information about derefs is not present in @reflist. So the answer is that you can't derive %refs from @reflist.

-- 
Jakub Narebski
ShadeHawk on #git
Poland
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 9 in “Make git_get_refs_list do work of git_get_references”
  1. 0/2 Make git_get_refs_list do work of git_get_referencesJakub Narebski, Sep 19, 2006
  2. 1/2 gitweb: Always use git-peek-remote in git_get_referencesJakub Narebski, Sep 19, 2006
  3. Junio C HamanoSep 20, 2006
  4. Jakub NarebskiSep 20, 2006
  5. Andreas EricssonSep 21, 2006
  6. 2/2 gitweb: Make git_get_refs_list do work of git_get_referencesJakub Narebski, Sep 19, 2006
  7. Junio C HamanoSep 20, 2006
  8. Jakub NarebskiSep 20, 2006
  9. Junio C HamanoSep 20, 2006

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.