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

Re: [PATCH 3/3] name-rev: --weight option (WIP)

From
Jeff King <peff@peff.net>
Date
Aug 30, 2012, 03:51 UTC
Message-ID
<20120830035127.GB32268@sigill.intra.peff.net>
In-Reply-To
<1346275044-10171-4-git-send-email-gitster@pobox.com>
On Wed, Aug 29, 2012 at 02:17:24PM -0700, Junio C Hamano wrote:
> Instead of naming a rev after a tip that is topologically closest,
> use the tip that is the oldest one among those which contain the
> rev.

When you wrote "oldest" here, I thought that meant you would do a comparison on the taggerdate. But reading the implementation, you really mean "topologically oldest".

I wonder, though, if the former would be sufficient for most people. Or even just sorting based on the tag name. For example, taking Greg's original example:

  $ commit=0136db586c028f71e7cc21cc183064ff0d5919
  $ oldest_tag=`git tag --contains $commit | sort -V | head -1`
  $ git name-rev --refs="refs/tags/$oldest_tag" $commit
  0136db586c028f71e7cc21cc183064ff0d5919 tags/v3.5~335^2~81^2~76

Of course "sort -V" is not portable, and it actually places -rc tags after release tags (note that we found v3.5 here, not v3.5-rc1). But that is an implementation detail that could be solved (either by a better comparison function, or by just using taggerdate instead).

In some ways it is not as elegant (clock skew in your tag dates would be relevant), but it is simple and performs well without needing to manage a cache.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 19 in “Funny 'git describe --contains' output”
  1. Greg KHAug 29, 2012
  2. Junio C HamanoAug 29, 2012
  3. Junio C HamanoAug 29, 2012
  4. Greg KHAug 29, 2012
  5. 0/3 "git name-rev --weight"Junio C Hamano, Aug 29, 2012
  6. 1/3 name-rev: lose unnecessary typedefJunio C Hamano, Aug 29, 2012
  7. 2/3 name_rev: clarify when a new tip-name is assigned to a commitJunio C Hamano, Aug 29, 2012
  8. 3/3 name-rev: --weight option (WIP)Junio C Hamano, Aug 29, 2012
  9. Junio C HamanoAug 29, 2012
  10. Jeff KingAug 30, 2012
  11. Junio C HamanoAug 30, 2012
  12. Jeff KingAug 30, 2012
  13. Junio C HamanoAug 30, 2012
  14. Junio C HamanoAug 30, 2012
  15. Junio C HamanoAug 30, 2012
  16. Jeff KingAug 30, 2012
  17. Junio C HamanoAug 30, 2012
  18. Philip OakleyAug 30, 2012
  19. Junio C HamanoAug 30, 2012

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.