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

Re: [PATCH 00/21] Introduce `USE_THE_REPOSITORY_VARIABLE` macro

From
Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Date
Jun 12, 2024, 10:12 UTC
Message-ID
<nvvhy5jofnvke22xpwauimfk55gnoq4arl5xo6yi7uycevxkt5@gvumdjdsoatp>
In-Reply-To
<ZmlQQadfFyCHo_k1@tanuki>
On Wed, 12 Jun 2024, Patrick Steinhardt <ps@pks.im> wrote:
Show 43 quoted lines
> On Tue, Jun 11, 2024 at 11:24:30PM +0000, brian m. carlson wrote:
> > On 2024-06-11 at 11:57:33, Patrick Steinhardt wrote:
> > > Hi,
> > > 
> > > use of the `the_repository` variable is nowadays considered to be
> > > deprecated, and over time we want to convert our codebase to stop using
> > > it in favor of explicitly passing down the repository to functions via
> > > parameters. This effort faces some important problems though.
> > > 
> > >   - It is hard to prove that a certain code unit does not use
> > >     `the_repository` anymore when sending patch series. The reviewer has
> > >     no way to verify that it's not used anymore without reading through
> > >     the code itself.
> > > 
> > >   - It is easy to sneak in new usages of `the_repository` by accident
> > >     into a code unit that is already `the_repository`-clean.
> > > 
> > >   - There are many functions which implicitly use `the_repository`,
> > >     which is really hard to spot.
> > > 
> > > This patch series aims to address those problems by introducing a new
> > > `USE_THE_REPOSITORY_VARIABLE` macro. When unset, then the declarations
> > > of `the_repository`, `the_hash_algo` and some functions that implicitly
> > > depend on them will be hidden away. This makes it trivial to demonstrate
> > > that a code unit is `the_repository`-free by removing the definition of
> > > any such macro.
> > 
> > Overall, I left a few comments, but I think this definitely moves us in
> > the right direction and I'm glad to see it.  This obviously improves the
> > experience with libification and unit testing in a lot of ways, which is
> > good.
> > 
> > My only caution is that using the *_any functions will cause us a world
> > of pain if we ever adopt another 256-bit hash function, since it will be
> > ambiguous which algorithm is to be used.  That's why, traditionally, we
> > haven't assumed a hash algorithm based on the object ID length.  I don't
> > think the amount of uses we have is excessive, even with your changes,
> > but we'll need to be mindful of that going forward.
> 
> The only cases where I add new calls to `_any()` are in test helpers:
> 
>   - "t/helper/test-oidtree.c". This one is getting converted to a unit
>     test by Ghanshyam, so I'll leave it to him to improve this.
Yeah, I don't use '_any()', and explicitly give algo using '_algop()'.
link:https://lore.kernel.org/git/20240608165731.29467-1-shyamthakkar001@gmail.com/
Thanks.
Show 13 quoted lines
>   - "t/helper/test-proc-receive.c". Here we don't care about the actual
>     algorithm, the only thing we care about is that we can correctly
>     parse them and then eventually emit them via `oid_to_hex()` again.
>     So even if we introduce a second hash function with the same length
>     this code would continue to work alright.
> 
> So I think it should be fine in the context of this series. But the
> remark is certainly valid and something we should be cautious about
> going forward.
> 
> Thanks!
> 
> Patrick
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 32 of 94 in “Introduce `USE_THE_REPOSITORY_VARIABLE` macro”
  1. 00/21 Introduce `USE_THE_REPOSITORY_VARIABLE` macroPatrick Steinhardt, Jun 11, 2024
  2. 01/21 hash: drop (mostly) unused `is_empty_{blob,tree}_sha1()` functionsPatrick Steinhardt, Jun 11, 2024
  3. 02/21 hash: require hash algorithm in `hasheq()`, `hashcmp()` and `hashclr()`Patrick Steinhardt, Jun 11, 2024
  4. 03/21 hash: require hash algorithm in `oidread()` and `oidclr()`Patrick Steinhardt, Jun 11, 2024
  5. 04/21 global: ensure that object IDs are always paddedPatrick Steinhardt, Jun 11, 2024
  6. 05/21 hash: convert `oidcmp()` and `oideq()` to compare whole hashPatrick Steinhardt, Jun 11, 2024
  7. 06/21 hash: make `is_null_oid()` independent of `the_repository`Patrick Steinhardt, Jun 11, 2024
  8. 07/21 hash: require hash algorithm in `is_empty_{blob,tree}_oid()`Patrick Steinhardt, Jun 11, 2024
  9. 08/21 hash: require hash algorithm in `empty_tree_oid_hex()`Patrick Steinhardt, Jun 11, 2024
  10. 09/21 global: introduce `USE_THE_REPOSITORY_VARIABLE` macroPatrick Steinhardt, Jun 11, 2024
  11. 10/21 refs: avoid include cycle with "repository.h"Patrick Steinhardt, Jun 11, 2024
  12. 11/21 hash-ll: merge with "hash.h"Patrick Steinhardt, Jun 11, 2024
  13. 12/21 http-fetch: don't crash when parsing packfile without a repoPatrick Steinhardt, Jun 11, 2024
  14. 13/21 oidset: pass hash algorithm when parsing filePatrick Steinhardt, Jun 11, 2024
  15. 14/21 protocol-caps: use hash algorithm from passed-in repositoryPatrick Steinhardt, Jun 11, 2024
  16. 15/21 replace-object: use hash algorithm from passed-in repositoryPatrick Steinhardt, Jun 11, 2024
  17. 16/21 compat/fsmonitor: remove dependency on `the_repository` in Darwin IPCPatrick Steinhardt, Jun 11, 2024
  18. brian m. carlsonJun 11, 2024
  19. Patrick SteinhardtJun 12, 2024
  20. 17/21 t/helper: use correct object hash in partial-clone helperPatrick Steinhardt, Jun 11, 2024
  21. 18/21 t/helper: fix segfault in "oid-array" command without repositoryPatrick Steinhardt, Jun 11, 2024
  22. Ghanshyam ThakkarJun 11, 2024
  23. 19/21 t/helper: remove dependency on `the_repository` in "oidtree"Patrick Steinhardt, Jun 11, 2024
  24. Ghanshyam ThakkarJun 11, 2024
  25. Patrick SteinhardtJun 12, 2024
  26. brian m. carlsonJun 11, 2024
  27. Patrick SteinhardtJun 12, 2024
  28. 20/21 t/helper: remove dependency on `the_repository` in "proc-receive"Patrick Steinhardt, Jun 11, 2024
  29. 21/21 hex: guard declarations with `USE_THE_REPOSITORY_VARIABLE`Patrick Steinhardt, Jun 11, 2024
  30. brian m. carlsonJun 11, 2024
  31. Patrick SteinhardtJun 12, 2024
  32. Ghanshyam ThakkarJun 12, 2024
  33. 00/20 Introduce `USE_THE_REPOSITORY_VARIABLE` macroPatrick Steinhardt, Jun 13, 2024
  34. 01/20 hash: drop (mostly) unused `is_empty_{blob,tree}_sha1()` functionsPatrick Steinhardt, Jun 13, 2024
  35. 02/20 hash: require hash algorithm in `hasheq()`, `hashcmp()` and `hashclr()`Patrick Steinhardt, Jun 13, 2024
  36. 03/20 hash: require hash algorithm in `oidread()` and `oidclr()`Patrick Steinhardt, Jun 13, 2024
  37. 04/20 global: ensure that object IDs are always paddedPatrick Steinhardt, Jun 13, 2024
  38. 05/20 hash: convert `oidcmp()` and `oideq()` to compare whole hashPatrick Steinhardt, Jun 13, 2024
  39. 06/20 hash: make `is_null_oid()` independent of `the_repository`Patrick Steinhardt, Jun 13, 2024
  40. 07/20 hash: require hash algorithm in `is_empty_{blob,tree}_oid()`Patrick Steinhardt, Jun 13, 2024
  41. 08/20 hash: require hash algorithm in `empty_tree_oid_hex()`Patrick Steinhardt, Jun 13, 2024
  42. Phillip WoodJun 13, 2024
  43. Junio C HamanoJun 13, 2024
  44. Patrick SteinhardtJun 14, 2024
  45. 09/20 global: introduce `USE_THE_REPOSITORY_VARIABLE` macroPatrick Steinhardt, Jun 13, 2024
  46. 10/20 refs: avoid include cycle with "repository.h"Patrick Steinhardt, Jun 13, 2024
  47. 11/20 hash-ll: merge with "hash.h"Patrick Steinhardt, Jun 13, 2024
  48. 12/20 http-fetch: don't crash when parsing packfile without a repoPatrick Steinhardt, Jun 13, 2024
  49. 13/20 oidset: pass hash algorithm when parsing filePatrick Steinhardt, Jun 13, 2024
  50. 14/20 protocol-caps: use hash algorithm from passed-in repositoryPatrick Steinhardt, Jun 13, 2024
  51. 15/20 replace-object: use hash algorithm from passed-in repositoryPatrick Steinhardt, Jun 13, 2024
  52. 16/20 compat/fsmonitor: fix socket path in networked SHA256 reposPatrick Steinhardt, Jun 13, 2024
  53. 17/20 t/helper: use correct object hash in partial-clone helperPatrick Steinhardt, Jun 13, 2024
  54. 18/20 t/helper: fix segfault in "oid-array" command without repositoryPatrick Steinhardt, Jun 13, 2024
  55. 19/20 t/helper: remove dependency on `the_repository` in "proc-receive"Patrick Steinhardt, Jun 13, 2024
  56. 20/20 hex: guard declarations with `USE_THE_REPOSITORY_VARIABLE`Patrick Steinhardt, Jun 13, 2024
  57. Junio C HamanoJun 13, 2024
  58. Junio C HamanoJun 13, 2024
  59. Ramsay JonesJun 13, 2024
  60. Junio C HamanoJun 13, 2024
  61. Ramsay JonesJun 13, 2024
  62. Junio C HamanoJun 14, 2024
  63. Patrick SteinhardtJun 14, 2024
  64. Junio C HamanoJun 14, 2024
  65. 00/20 Introduce `USE_THE_REPOSITORY_VARIABLE` macroPatrick Steinhardt, Jun 14, 2024
  66. 01/20 hash: drop (mostly) unused `is_empty_{blob,tree}_sha1()` functionsPatrick Steinhardt, Jun 14, 2024
  67. 02/20 hash: require hash algorithm in `hasheq()`, `hashcmp()` and `hashclr()`Patrick Steinhardt, Jun 14, 2024
  68. 03/20 hash: require hash algorithm in `oidread()` and `oidclr()`Patrick Steinhardt, Jun 14, 2024
  69. 04/20 global: ensure that object IDs are always paddedPatrick Steinhardt, Jun 14, 2024
  70. 05/20 hash: convert `oidcmp()` and `oideq()` to compare whole hashPatrick Steinhardt, Jun 14, 2024
  71. Karthik NayakJun 17, 2024
  72. 06/20 hash: make `is_null_oid()` independent of `the_repository`Patrick Steinhardt, Jun 14, 2024
  73. 07/20 hash: require hash algorithm in `is_empty_{blob,tree}_oid()`Patrick Steinhardt, Jun 14, 2024
  74. 08/20 hash: require hash algorithm in `empty_tree_oid_hex()`Patrick Steinhardt, Jun 14, 2024
  75. 09/20 global: introduce `USE_THE_REPOSITORY_VARIABLE` macroPatrick Steinhardt, Jun 14, 2024
  76. Karthik NayakJun 17, 2024
  77. Patrick SteinhardtJun 18, 2024
  78. Karthik NayakJun 18, 2024
  79. Junio C HamanoJun 18, 2024
  80. Junio C HamanoJun 18, 2024
  81. Karthik NayakJun 18, 2024
  82. 10/20 refs: avoid include cycle with "repository.h"Patrick Steinhardt, Jun 14, 2024
  83. 11/20 hash-ll: merge with "hash.h"Patrick Steinhardt, Jun 14, 2024
  84. 12/20 http-fetch: don't crash when parsing packfile without a repoPatrick Steinhardt, Jun 14, 2024
  85. 13/20 oidset: pass hash algorithm when parsing filePatrick Steinhardt, Jun 14, 2024
  86. 14/20 protocol-caps: use hash algorithm from passed-in repositoryPatrick Steinhardt, Jun 14, 2024
  87. 15/20 replace-object: use hash algorithm from passed-in repositoryPatrick Steinhardt, Jun 14, 2024
  88. 16/20 compat/fsmonitor: fix socket path in networked SHA256 reposPatrick Steinhardt, Jun 14, 2024
  89. 17/20 t/helper: use correct object hash in partial-clone helperPatrick Steinhardt, Jun 14, 2024
  90. 18/20 t/helper: fix segfault in "oid-array" command without repositoryPatrick Steinhardt, Jun 14, 2024
  91. 19/20 t/helper: remove dependency on `the_repository` in "proc-receive"Patrick Steinhardt, Jun 14, 2024
  92. 20/20 hex: guard declarations with `USE_THE_REPOSITORY_VARIABLE`Patrick Steinhardt, Jun 14, 2024
  93. Phillip WoodJun 18, 2024
  94. Karthik NayakJun 18, 2024

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.