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

Re: [PATCH 00/22] Refactor to accept NUL in commit messages

From
Jeff King <peff@peff.net>
Date
Oct 22, 2011, 19:09 UTC
Message-ID
<20111022190914.GA1785@sigill.intra.peff.net>
In-Reply-To
<1319277881-4128-1-git-send-email-pclouds@gmail.com>
On Sat, Oct 22, 2011 at 09:04:19PM +1100, Nguyen Thai Ngoc Duy wrote:
> This series helps pass commit message size up to output functions,
> though it does not change any output functions to print ^@.

Can we take a step back for a second and discuss what git _should_ do with commits that contain NUL?

If all of the pretty-print functions are just going consider "foo\0bar" to be "foo^@bar", then maybe it would be much simpler to just "normalize" the commit message into a C string at a lower level, and pass it around as a string as we currently do.

On the other hand, if we are eventually looking to add an option like "--include-NUL-in-commit-message", then it would make sense for the real contents and size to get passed around.

Show 5 quoted lines
> All functions up to the last patch learn to accept a string as a pair
> <const char *start, const char *end> as a preparation step. These
> changes are relatively simple. Or it could have been so if I did not
> attempt to reduce some code duplication found while working on this
> series.
Great. Reducing code duplication is always a plus.
> The last patch turns commit_buffer field in struct commit to "struct
> strbuf *". This approach costs us 12 bytes more each commit. We can
> choose not to use strbuf to save memory.

I think 12 bytes in the commit struct might be noticeable. But it looks like you've done the sane thing, and replaced the pointer-to-char with a pointer-to-strbuf. And that I don't think should be a big deal. The buffer itself is way bigger than 12 bytes, so we don't care so much about the "we have a buffer" case, but more about the 100,000 other commits that we're not currently printing right now.

Of course, some timings on things like "rev-list" and "pack-objects" would be nice to double-check.

-Peff
Next: Robin Rosenberg
Message 1 of 26 in “Re: [PATCH 00/22] Refactor to accept NUL in commit messages”
  1. Jeff KingOct 22, 2011
  2. Robin RosenbergOct 23, 2011
  3. Jeff KingOct 23, 2011
  4. Junio C HamanoOct 22, 2011
  5. Nguyen Thai Ngoc DuyOct 23, 2011
  6. Junio C HamanoOct 23, 2011
  7. Nguyen Thai Ngoc DuyOct 23, 2011
  8. Junio C HamanoOct 23, 2011
  9. Nguyen Thai Ngoc DuyOct 23, 2011
  10. Jeff KingOct 23, 2011
  11. Junio C HamanoOct 23, 2011
  12. Junio C HamanoOct 24, 2011
  13. Nguyen Thai Ngoc DuyOct 24, 2011
  14. Štěpán NěmecOct 24, 2011
  15. Jeff KingOct 24, 2011
  16. Štěpán NěmecOct 25, 2011
  17. Junio C HamanoOct 25, 2011
  18. Jeff KingOct 27, 2011
  19. Junio C HamanoOct 27, 2011
  20. Jeff KingOct 27, 2011
  21. Junio C HamanoOct 27, 2011
  22. Jeff KingOct 27, 2011
  23. Junio C HamanoOct 28, 2011
  24. Jeff KingOct 28, 2011
  25. Miles BaderOct 28, 2011
  26. Junio C HamanoOct 28, 2011

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.