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

Re: [PATCH 12/31] fast-import: make hash-size independent

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 12, 2019, 23:36 UTC
Message-ID
<20190212233648.GF684736@genre.crustytoothpaste.net>
In-Reply-To
<CAPig+cQivuPjDztK30QO0xKx1Tx+nYDPzTvgXvi9WVyRX5-aRQ@mail.gmail.com>
On Mon, Feb 11, 2019 at 10:44:12PM -0500, Eric Sunshine wrote:
Show 18 quoted lines
> On Mon, Feb 11, 2019 at 8:23 PM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> > Replace several uses of GIT_SHA1_HEXSZ and 40-based constants with
> > references to the_hash_algo.  Update the note handling code here to
> > compute path sizes based on GIT_MAX_RAWSZ as well.
> >
> > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> > ---
> > diff --git a/fast-import.c b/fast-import.c
> > @@ -2047,7 +2047,8 @@ static uintmax_t do_change_note_fanout(
> > -       char realpath[60];
> > +       char realpath[GIT_MAX_RAWSZ * 3];
> 
> I wonder if the fixed multiplier deserves a comment explaining that
> this is reserving enough space for a hex representation with '/'
> between each digit pair plus NUL. Which leads to the next question: Is
> there is GIT_MAX_HEXSZ constant? If so, this might be more clearly
> represented (or not) by taking advantage of that value.

There is such a constant. I'll add a comment and see if I can write it in a way that makes it more intuitive what we're computing.

Show 9 quoted lines
> Also, there are a number of hardcoded 60's in the code earlier in this
> file, such as:
> 
>     if ((max_packsize && (pack_size + 60 + len) > max_packsize)
>         || (pack_size + 60 + len) < pack_size)
>         cycle_packfile();
> 
> Is that just a coincidence or is it related to the 60 characters
> allocated for 'realpath'?

That's an interesting question. It looks like these are indeed related to the hash size, but they're not related to the realpath call above. I'll convert them as well.

Show 13 quoted lines
> > @@ -2405,7 +2406,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
> >                 char *buf = read_object_with_reference(&commit_oid,
> >                                                        commit_type, &size,
> >                                                        &commit_oid);
> > -               if (!buf || size < 46)
> > +               if (!buf || size < the_hash_algo->hexsz)
> 
> What exactly did the 46 represent and how does it relate to 'hexsz'?
> Stated differently, why didn't this become:
> 
>     the_hash_algo->hexsz + 6'
> 
> ?

Good catch. I believe that 46 is the number of bytes in "tree %s\n", which is the smallest possible commit (a root commit without an author or committer).

I'll fix this misconversion.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Eric SunshineNext: brian m. carlson
Message 28 of 56 in “Hash function transition part 16”
  1. 00/31 Hash function transition part 16brian m. carlson, Feb 12, 2019
  2. 01/31 t/lib-submodule-update: use appropriate length constantbrian m. carlson, Feb 12, 2019
  3. 03/31 pack-bitmap: convert struct stored_bitmap to object_idbrian m. carlson, Feb 12, 2019
  4. 02/31 pack-bitmap: make bitmap header handling hash agnosticbrian m. carlson, Feb 12, 2019
  5. 05/31 pack-bitmap: switch hard-coded constants to the_hash_algobrian m. carlson, Feb 12, 2019
  6. Ævar Arnfjörð BjarmasonFeb 12, 2019
  7. 04/31 pack-bitmap: replace sha1_to_hexbrian m. carlson, Feb 12, 2019
  8. Jeff KingFeb 12, 2019
  9. brian m. carlsonFeb 13, 2019
  10. Jeff KingFeb 14, 2019
  11. 08/31 notes: make hash size independentbrian m. carlson, Feb 12, 2019
  12. Eric SunshineFeb 12, 2019
  13. brian m. carlsonFeb 12, 2019
  14. 09/31 notes: replace sha1_to_hexbrian m. carlson, Feb 12, 2019
  15. 11/31 builtin/name-rev: make hash-size independentbrian m. carlson, Feb 12, 2019
  16. 06/31 submodule: avoid hard-coded constantsbrian m. carlson, Feb 12, 2019
  17. 10/31 object-store: rename and expand packed_git's sha1 memberbrian m. carlson, Feb 12, 2019
  18. Eric SunshineFeb 12, 2019
  19. brian m. carlsonFeb 14, 2019
  20. 14/31 builtin/am: make hash size independentbrian m. carlson, Feb 12, 2019
  21. 15/31 builtin/pull: make hash-size independentbrian m. carlson, Feb 12, 2019
  22. Eric SunshineFeb 12, 2019
  23. 13/31 fast-import: replace sha1_to_hexbrian m. carlson, Feb 12, 2019
  24. 17/31 http-backend: allow 64-character hex namesbrian m. carlson, Feb 12, 2019
  25. 16/31 http-push: convert to use the_hash_algobrian m. carlson, Feb 12, 2019
  26. 12/31 fast-import: make hash-size independentbrian m. carlson, Feb 12, 2019
  27. Eric SunshineFeb 12, 2019
  28. brian m. carlsonFeb 12, 2019
  29. 18/31 http-push: remove remaining uses of sha1_to_hexbrian m. carlson, Feb 12, 2019
  30. 20/31 http: replace hard-coded constant with the_hash_algobrian m. carlson, Feb 12, 2019
  31. 22/31 http: replace sha1_to_hexbrian m. carlson, Feb 12, 2019
  32. 21/31 http: compute hash of downloaded objects using the_hash_algobrian m. carlson, Feb 12, 2019
  33. 23/31 remote-curl: make hash size independentbrian m. carlson, Feb 12, 2019
  34. Ævar Arnfjörð BjarmasonFeb 12, 2019
  35. 19/31 http-walker: replace sha1_to_hexbrian m. carlson, Feb 12, 2019
  36. Eric SunshineFeb 12, 2019
  37. 29/31 read-cache: read data in a hash-independent waybrian m. carlson, Feb 12, 2019
  38. 28/31 dir: make untracked cache extension hash size independentbrian m. carlson, Feb 12, 2019
  39. Ævar Arnfjörð BjarmasonFeb 12, 2019
  40. brian m. carlsonFeb 13, 2019
  41. 25/31 archive: convert struct archiver_args to object_idbrian m. carlson, Feb 12, 2019
  42. 26/31 refspec: make hash size independentbrian m. carlson, Feb 12, 2019
  43. 31/31 gitweb: make hash size independentbrian m. carlson, Feb 12, 2019
  44. Ævar Arnfjörð BjarmasonFeb 12, 2019
  45. 30/31 Git.pm: make hash size independentbrian m. carlson, Feb 12, 2019
  46. Ævar Arnfjörð BjarmasonFeb 12, 2019
  47. brian m. carlsonFeb 18, 2019
  48. Ævar Arnfjörð BjarmasonFeb 18, 2019
  49. 24/31 archive-tar: make hash size independentbrian m. carlson, Feb 12, 2019
  50. René ScharfeFeb 12, 2019
  51. René ScharfeFeb 12, 2019
  52. brian m. carlsonFeb 13, 2019
  53. 27/31 builtin/difftool: use parse_oid_hexbrian m. carlson, Feb 12, 2019
  54. Eric SunshineFeb 12, 2019
  55. 07/31 notes-merge: switch to use the_hash_algobrian m. carlson, Feb 12, 2019
  56. Ævar Arnfjörð BjarmasonFeb 12, 2019

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.