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

Re: [PATCH 07/17] commit: increase commit message buffer size

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 9, 2018, 23:39 UTC
Message-ID
<20180709233952.GB535220@genre.crustytoothpaste.net>
In-Reply-To
<xmqqva9oe20y.fsf@gitster-ct.c.googlers.com>
On Mon, Jul 09, 2018 at 10:45:33AM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> Derrick Stolee <stolee@gmail.com> writes:
> 
> > On 7/8/2018 7:36 PM, brian m. carlson wrote:
> >> diff --git a/refs/files-backend.c b/refs/files-backend.c
> >> index a9a066dcfb..252f835bae 100644
> >> --- a/refs/files-backend.c
> >> +++ b/refs/files-backend.c
> >> @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
> >>   	char *logrec;
> >>     	msglen = msg ? strlen(msg) : 0;
> >> -	maxlen = strlen(committer) + msglen + 100;
> >> +	maxlen = strlen(committer) + msglen + 200;
> >>   	logrec = xmalloc(maxlen);
> >>   	len = xsnprintf(logrec, maxlen, "%s %s %s\n",
> >>   			oid_to_hex(old_oid),
> >
> > nit: 100 is not enough anymore, but wasn't a very descriptive
> > value. 200 may be enough now, but I'm not sure why.

200 is definitely enough. Suppose we had a message consisting entirely of SHA-1 hashes (5, at 20 bytes a piece). If our new hash is 32 bytes long, then it would require at most 160 bytes.

I only noticed this because the old code segfaulted. My approach to using a 32-byte hash was to set it up, do some basic tests, find out what crashed, and fix it. Most of this series is the basics necessary to get the most rudimentary functionality out of a 32-byte Git, excluding the index pieces, which are necessarily inelegant.

I didn't include them because there are other ways to implement the changes which are more elegant in some ways and less elegant in other ways, and I want to think more about it before I send them in.

> As Brandon alludes to downthread, we probably should use strbuf for
> things like this these days, so a preliminary clean-up to do so is
> probably a welcome change to sneak in and rebase this series on top
> of.

Sure, I agree that would be a better change, and I'm happy to reroll with that.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Junio C HamanoNext: Junio C Hamano
Message 26 of 37 in “object_id part 14”
  1. 00/17 object_id part 14brian m. carlson, Jul 8, 2018
  2. 01/17 cache: update object ID functions for the_hash_algobrian m. carlson, Jul 8, 2018
  3. Jacob KellerJul 9, 2018
  4. Eric SunshineJul 9, 2018
  5. Jacob KellerJul 9, 2018
  6. brian m. carlsonJul 9, 2018
  7. 04/17 commit: express tree entry constants in terms of the_hash_algobrian m. carlson, Jul 8, 2018
  8. 06/17 sha1-name: use the_hash_algo when parsing object namesbrian m. carlson, Jul 8, 2018
  9. 05/17 strbuf: allocate space with GIT_MAX_HEXSZbrian m. carlson, Jul 8, 2018
  10. 10/17 builtin/update-index: simplify parsing of cacheinfobrian m. carlson, Jul 8, 2018
  11. 11/17 builtin/fmt-merge-msg: make hash independentbrian m. carlson, Jul 8, 2018
  12. 14/17 diff: switch GIT_SHA1_HEXSZ to use the_hash_algobrian m. carlson, Jul 8, 2018
  13. 13/17 builtin/merge-recursive: make hash independentbrian m. carlson, Jul 8, 2018
  14. 17/17 pretty: switch hard-coded constants to the_hash_algobrian m. carlson, Jul 8, 2018
  15. 15/17 log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexszbrian m. carlson, Jul 8, 2018
  16. 16/17 sha1-file: convert constants to uses of the_hash_algobrian m. carlson, Jul 8, 2018
  17. 12/17 builtin/merge: switch to use the_hash_algobrian m. carlson, Jul 8, 2018
  18. 09/17 builtin/update-index: convert to using the_hash_algobrian m. carlson, Jul 8, 2018
  19. 07/17 commit: increase commit message buffer sizebrian m. carlson, Jul 8, 2018
  20. Derrick StoleeJul 9, 2018
  21. Stefan BellerJul 9, 2018
  22. Brandon WilliamsJul 9, 2018
  23. Junio C HamanoJul 9, 2018
  24. Brandon WilliamsJul 9, 2018
  25. Junio C HamanoJul 9, 2018
  26. brian m. carlsonJul 9, 2018
  27. Junio C HamanoJul 10, 2018
  28. Ben PeartJul 10, 2018
  29. brian m. carlsonJul 11, 2018
  30. Junio C HamanoJul 11, 2018
  31. 08/17 refs/files-backend: use the_hash_algo for writing refsbrian m. carlson, Jul 8, 2018
  32. 02/17 tree-walk: replace hard-coded constants with the_hash_algobrian m. carlson, Jul 8, 2018
  33. 03/17 hex: switch to using the_hash_algobrian m. carlson, Jul 8, 2018
  34. Jacob KellerJul 9, 2018
  35. Derrick StoleeJul 9, 2018
  36. Michael HaggertyJul 14, 2018
  37. Junio C HamanoJul 16, 2018

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.