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

Re: [RFC/PATCH] tag: add --points-at list option

From
Jeff King <peff@peff.net>
Date
Feb 6, 2012, 07:13 UTC
Message-ID
<20120206071302.GA10447@sigill.intra.peff.net>
In-Reply-To
<20120206070424.GC9931@sigill.intra.peff.net>
On Mon, Feb 06, 2012 at 02:04:24AM -0500, Jeff King wrote:
Show 14 quoted lines
> > >Before your patch, a tag whose sha1 could not be read would get its name
> > >printed, and then we would later return without printing anything more.
> > >Now it won't get even the first bit printed.
> > >
> > >However, I'm not sure the old behavior wasn't buggy; it would print part
> > >of the line, but never actually print the newline.
> > 
> > If you prefer, I can restore the old behavior just moving the
> > condition/return back below the refname print; then add "buf" qualifier
> > to the following fragment and at each intermediate free.
> 
> Thinking on it more, your behavior is at least as good as the old. And
> it only comes up in a broken repo, anyway, so trying to come up with
> some kind of useful outcome is pointless.

Sorry to reverse myself, but I just peeked at the show_reference function one more time. Unconditionally moving the buffer-reading up above the "if (!filter->lines)" conditional is not a good idea.

If I do "git tag -l", right now git doesn't have to actually read and parse each object that has been tagged (lightweight or not). If I use "git tag -n10", then obviously we do need to read it (and we do). And if we use your new "--points-at", we also do. But if neither of those options are in use, it would be nice to avoid the object lookup (it may not seem like much, but if you have a repo with an insane number of tags, it can add up).

Show 7 quoted lines
> BTW, writing that helped me notice two bugs in your patch:
> 
>   1. You read up to 47 bytes into the buffer without ever checking
>      whether size >= 47.
> 
>   2. You never check whether the object you read from read_sha1_file is
>      actually a tag.

Hmm, the "filter->lines" code for "git tag -n" makes a similar error. It should probably print nothing for objects that are not tags.

-Peff
Previous: Jeff KingNext: Jeff King
Message 9 of 53 in “tag: add --points-at list option”
  1. tag: add --points-at list optionTom Grennan, Feb 5, 2012
  2. Junio C HamanoFeb 5, 2012
  3. Tom GrennanFeb 6, 2012
  4. Junio C HamanoFeb 6, 2012
  5. Tom GrennanFeb 6, 2012
  6. Jeff KingFeb 6, 2012
  7. Tom GrennanFeb 6, 2012
  8. Jeff KingFeb 6, 2012
  9. Jeff KingFeb 6, 2012
  10. Jeff KingFeb 6, 2012
  11. Jeff KingFeb 6, 2012
  12. 1/3 tag: fix output of "tag -n" when errors occurJeff King, Feb 6, 2012
  13. 2/3 tag: die when listing missing or corrupt objectsJeff King, Feb 6, 2012
  14. Junio C HamanoFeb 6, 2012
  15. Jeff KingFeb 6, 2012
  16. Junio C HamanoFeb 6, 2012
  17. Jeff KingFeb 6, 2012
  18. Junio C HamanoFeb 6, 2012
  19. Junio C HamanoFeb 6, 2012
  20. Jeff KingFeb 6, 2012
  21. Junio C HamanoFeb 6, 2012
  22. Jeff KingFeb 8, 2012
  23. Junio C HamanoFeb 9, 2012
  24. 3/3 tag: don't show non-tag contents with "-n"Jeff King, Feb 6, 2012
  25. [PATCHv2] tag: add --points-at list optionTom Grennan, Feb 7, 2012
  26. [PATCHv2] tag: add --points-at list optionTom Grennan, Feb 7, 2012
  27. Junio C HamanoFeb 7, 2012
  28. Tom GrennanFeb 7, 2012
  29. Jeff KingFeb 7, 2012
  30. Tom GrennanFeb 7, 2012
  31. Jeff KingFeb 7, 2012
  32. Tom GrennanFeb 7, 2012
  33. Jeff KingFeb 7, 2012
  34. Junio C HamanoFeb 7, 2012
  35. Jeff KingFeb 7, 2012
  36. Tom GrennanFeb 7, 2012
  37. Jeff KingFeb 8, 2012
  38. Tom GrennanFeb 8, 2012
  39. Jeff KingFeb 8, 2012
  40. [PATCHv3] tag: add --points-at list optionTom Grennan, Feb 8, 2012
  41. [PATCHv3] tag: add --points-at list optionTom Grennan, Feb 8, 2012
  42. Jeff KingFeb 8, 2012
  43. Tom GrennanFeb 8, 2012
  44. Jeff KingFeb 8, 2012
  45. [PATCHv4] tag: add --points-at list optionTom Grennan, Feb 8, 2012
  46. [PATCHv4] tag: add --points-at list optionTom Grennan, Feb 8, 2012
  47. Jeff KingFeb 8, 2012
  48. Tom GrennanFeb 8, 2012
  49. tag: add --points-at list optionTom Grennan, Feb 8, 2012
  50. tag: add --points-at list optionTom Grennan, Feb 8, 2012
  51. Jeff KingFeb 9, 2012
  52. Junio C HamanoFeb 9, 2012
  53. Tom GrennanFeb 8, 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.