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

Re: [PATCH] gitweb: ref markers link to named shortlogs

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 22, 2008, 10:56 UTC
Message-ID
<200808221256.21805.jnareb@gmail.com>
In-Reply-To
<cb7bb73a0808220231w37d2341eic56cabb595399f68@mail.gmail.com>
On Fri, 22 August 2008, Giuseppe Bilotta wrote:
Show 40 quoted lines
> On Fri, Aug 22, 2008 at 10:49 AM, Jakub Narebski <jnareb@gmail.com> wrote:
> >
> > What format_ref_marker() uses is not exactly 'type' of reference, but
> > more 'kind of' reference.  It is based on reference namespace, not
> > on type of object the reference is at (points to).  So code based
> > on this info (like your v3 patch) would fail on lightweight tag, i.e.
> > if there is ref in 'refs/tags' namespace which points directly to commit,
> > and not to tag object.
> >
> > But 'git show-ref --dereference' _has_ information about whether
> > given reference points directly or indirectly to given object
> > ($refs->{$id}), but currently we neither save it, nor use it.
> > For example we can have:
> >
> >  781c1834f5419bdf81bb7f3750170ccd6b809174 refs/heads/maint
> >  ...
> >  124c62e8781a8f03ee0256bee78f7b392e3920af refs/stash
> >  ...
> >  89e6fcde639d65823e8113c307067441701ac74f refs/tags/Attic/gitweb/parse_rev_list
> >  b69a41a384d19fe253b9f4f34c9019ad96ca571d refs/tags/Attic/gitweb/patchset_body
> >  781c1834f5419bdf81bb7f3750170ccd6b809174 refs/tags/TEMP
> >  ...
> >  07cca3b30ee2b5d060e44e5b18d7c22929c63d1a refs/tags/v1.5.6.5
> >  781c1834f5419bdf81bb7f3750170ccd6b809174 refs/tags/v1.5.6.5^{}
> >
> > Now in this example we have three refs pointing to commit object
> > 781c1834: refs/heads/maint, refs/tags/TEMP and refs/tags/v1.5.6.5.
> > From those only refs/tags/v1.5.6.5 is (via) tag, even though TEMP
> > is in tags namespace.  Currently git_get_references() strips '^{}'
> > indirect reference marker from the output (from refname), and doesn't
> > make use of it.  One solution would be to not stip it in
> > git_get_references(), but leave it, and strip it and make use of
> > it (if ref ends with '^{}' it must be tag object) in format_ref_marker().
> 
> Ah, I see what you mean. If I understand correctly, this particular
> situation is only a problem with tags, as they can be either
> lighweight tags (that reference a commit) or actual tag objects (that
> are indirect references to commits and direct references to
> themselves), whereas everything else is just direct references to
> object.

Yes, properly managed git repository should have refs pointing to tag objects only in 'refs/tags' (tags) namespace.

> Handling this requires a couple of extra info to be carried 
> over in $refs, so I guess I'll have to experiment with it  a little
> since it would require a more extensive change than I originally
> planned.

This "couple of extra info" could be just '^{}' suffix. So I don't think it would be very complicated.

You could simply do not strip '^{}' suffix in git_get_references() subroutine (so for example $refs->{$id} could be "tags/v1.6.0^{}", and not simply "tags/v1.6.0" when $id is sha-1 of a _commit_ indirectly referenced by v1.6.0, i.e. referenced by v1.6.0 _tag_), and strip it and make use of it in format_ref_marker():

   if ($ref =~ s/\^\{\}$//) {
      # $ref is a tag
   } else {
      # $ref points directly to object
   }
HTH.
P.S. I have re-added git mailing list to Cc:.
-- 
Jakub Narebski
Poland
Previous: Jakub NarebskiNext: Giuseppe Bilotta
Message 18 of 33 in “gitweb: ref markers link to named shortlogs”
  1. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 21, 2008
  2. Jakub NarebskiAug 21, 2008
  3. Giuseppe BilottaAug 22, 2008
  4. Jakub NarebskiAug 22, 2008
  5. [PATCHv3] gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 22, 2008
  6. Lea WiemannAug 24, 2008
  7. Giuseppe BilottaAug 24, 2008
  8. Jakub NarebskiAug 24, 2008
  9. Giuseppe BilottaAug 25, 2008
  10. Jakub NarebskiAug 26, 2008
  11. Giuseppe BilottaAug 26, 2008
  12. Jakub NarebskiAug 26, 2008
  13. Giuseppe BilottaAug 26, 2008
  14. Giuseppe BilottaAug 27, 2008
  15. Lea WiemannAug 28, 2008
  16. Giuseppe BilottaAug 28, 2008
  17. Jakub NarebskiAug 28, 2008
  18. Jakub NarebskiAug 22, 2008
  19. Giuseppe BilottaAug 22, 2008
  20. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 22, 2008
  21. Jakub NarebskiAug 22, 2008
  22. Giuseppe BilottaAug 22, 2008
  23. Jakub NarebskiAug 22, 2008
  24. Giuseppe BilottaAug 22, 2008
  25. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 22, 2008
  26. Jakub NarebskiAug 24, 2008
  27. Miklos VajnaAug 25, 2008
  28. Jakub NarebskiAug 25, 2008
  29. Junio C HamanoAug 25, 2008
  30. Jakub NarebskiAug 25, 2008
  31. Junio C HamanoAug 25, 2008
  32. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 26, 2008
  33. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 26, 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.