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

Re: [PATCH v2 0/2] Add support for %(contents:size) in ref-filter

From
Christian Couder <christian.couder@gmail.com>
Date
Jul 7, 2020, 06:19 UTC
Message-ID
<CAP8UFD0gUK4TGUA7JZ_V7hFe4LSDAP7DfPyz4gqy1RjLXJPF2w@mail.gmail.com>
In-Reply-To
<20200707050247.GA105016@coredump.intra.peff.net>
On Tue, Jul 7, 2020 at 7:02 AM Jeff King <peff@peff.net> wrote:
>
> On Thu, Jul 02, 2020 at 04:08:43PM +0200, Christian Couder wrote:
Show 8 quoted lines
> > The other difference with V1 is that there are more tests in patch
> > 2/2. These new tests required a small helper function to be
> > introduced.
>
> I'm still not sure why %(objectsize) isn't sufficient here. Is there
> some use case that's served by %(contents:size) that it wouldn't work
> for? Or are we just trying to make it more discoverable when you're
> looking at the contents already?

%(objectsize) is the size of the whole commit or tag object, while %(contents:size) is the size of the complete message (the whole commit message or tag message, including trailers and signatures).

$ git for-each-ref --format='refname: %(refname)%0a%09objectsize:
%(objectsize)%0a%09contents:size: %(contents:size)'
refs/heads/{master,next,seen} refs/tags/v2.2{5,6,7}.0
refname: refs/heads/master
        objectsize: 285
        contents:size: 69
refname: refs/heads/next
        objectsize: 281
        contents:size: 17
refname: refs/heads/seen
        objectsize: 589
        contents:size: 325
refname: refs/tags/v2.25.0
        objectsize: 974
        contents:size: 842
refname: refs/tags/v2.26.0
        objectsize: 974
        contents:size: 842
refname: refs/tags/v2.27.0
        objectsize: 974
        contents:size: 842

When sending only the complete message, not the whole object, through a protocol, it might be interesting to easily get the length of the complete message. For example one could use "Content-Length: %(contents:size)%0a" when sending a complete message over HTTP.

Previous: Jeff KingNext: Jeff King
Message 9 of 10 in “Add support for %(contents:size) in ref-filter”
  1. 0/2 Add support for %(contents:size) in ref-filterChristian Couder, Jul 2, 2020
  2. 1/2 Documentation: clarify %(contents:XXXX) docChristian Couder, Jul 2, 2020
  3. Junio C HamanoJul 6, 2020
  4. 2/2 ref-filter: add support for %(contents:size)Christian Couder, Jul 2, 2020
  5. Junio C HamanoJul 6, 2020
  6. Christian CouderJul 7, 2020
  7. Junio C HamanoJul 7, 2020
  8. Jeff KingJul 7, 2020
  9. Christian CouderJul 7, 2020
  10. Jeff KingJul 8, 2020

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.