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

Re: [PATCH v2 14/14] update-index: remove static globals from callbacks

From
Derrick Stolee <stolee@gmail.com>
Date
Jan 8, 2021, 01:52 UTC
Message-ID
<e598f0e4-bdd9-4b59-f267-545204829a63@gmail.com>
In-Reply-To
<xmqq4kjsmses.fsf@gitster.c.googlers.com>
On 1/7/2021 2:57 PM, Junio C Hamano wrote:
Show 27 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> 
>>> It could be possible to replace all references to 'istate' with
>>> 'repo->index' but the patches get slightly more messy. I also
>>> think the code looks messier, but you do make a good point that
>>> there is no concrete reason to separate the two.
>>
>> I agree that it would make the code a bit noisier (to read) if
>> `istate` is eliminated from the callback structure, however, even
>> though I didn't originally feel strongly one way or the other about
>> having both `repo` and `istate` in the structure, I'm now leaning more
>> toward seeing `istate` eliminated. My one (big) concern with `istate`
>> is that it confuses readers into wondering whether `istate` and
>> `repo->istate` will ever be different.
> 
> Some applications may want to work on more than one in-core index at
> the same time (perhaps a merge strategy may want to keep a copy of
> the original index and update a second copy with the result of the
> merge), and it may be useful for such applications if 'repo->istate'
> does not have to be the in-core index instance to be worked on.  So
> things that go in libgit.a may want to allow such distinction.
> 
> But what goes in builtin/ is a different story.  As long as this
> application has no need for such a feature and will always work on
> the primary in-core index, prepared for the in-core repository
> structure for convenience, it may not worth it to support such a
> feature that no callers benefit from.
I'll try to restructure my patches to do the following order:
1. replace compatibility macros with static global references, except
   i. use 'istate' in the methods that don't need a repository.
  ii. use 'repo->index' in the methods that need a repository.
2. replace static globals with method parameters.
   i. drop 'istate' static global with method parameters. Methods that
      have a repo will pass 'repo->index' to these methods.
  ii. drop 'repo' static global with method parameters.
3. replace static globals in callback methods using 'repo->index',
   where 'repo' is a member of the callback_data struct.

That should keep the structure as presented in v2 while also avoiding this question of "can istate differ from repo->index?"

Thanks, -Stolee

Previous: Junio C HamanoNext: Derrick Stolee via GitGitGadget
Message 38 of 65 in “Remove more index compatibility macros”
  1. 00/12 Remove more index compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  2. 01/12 merge-index: drop index compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  3. Alban GruinJan 3, 2021
  4. Derrick StoleeJan 4, 2021
  5. 02/12 mv: remove index compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  6. 03/12 rm: remove compatilibity macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  7. 04/12 update-index: drop the_index, the_repositoryDerrick Stolee via GitGitGadget, Jan 1, 2021
  8. Elijah NewrenJan 1, 2021
  9. Derrick StoleeJan 4, 2021
  10. 07/12 update-index: use istate->cache_changedDerrick Stolee via GitGitGadget, Jan 1, 2021
  11. 06/12 update-index: use index->cache_nr over active_nrDerrick Stolee via GitGitGadget, Jan 1, 2021
  12. 10/12 update-index: use add_index_entry()Derrick Stolee via GitGitGadget, Jan 1, 2021
  13. 11/12 update-index: replace several compatibility macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  14. 09/12 update-index: use remove_file_from_index()Derrick Stolee via GitGitGadget, Jan 1, 2021
  15. 08/12 update-index: use index_name_pos() over cache_name_pos()Derrick Stolee via GitGitGadget, Jan 1, 2021
  16. 05/12 update-index: use istate->cache over active_cacheDerrick Stolee via GitGitGadget, Jan 1, 2021
  17. 12/12 update-index: remove ce_match_stat(), all macrosDerrick Stolee via GitGitGadget, Jan 1, 2021
  18. Elijah NewrenJan 1, 2021
  19. Elijah NewrenJan 1, 2021
  20. Eric SunshineJan 2, 2021
  21. Derrick StoleeJan 4, 2021
  22. Eric SunshineJan 4, 2021
  23. Derrick StoleeJan 5, 2021
  24. 00/14 Remove more index compatibility macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  25. 03/14 update-index: drop the_index, the_repositoryDerrick Stolee via GitGitGadget, Jan 5, 2021
  26. 02/14 rm: remove compatilibity macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  27. 01/14 mv: remove index compatibility macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  28. 04/14 update-index: use istate->cache over active_cacheDerrick Stolee via GitGitGadget, Jan 5, 2021
  29. 05/14 update-index: use index->cache_nr over active_nrDerrick Stolee via GitGitGadget, Jan 5, 2021
  30. 07/14 update-index: use index_name_pos() over cache_name_pos()Derrick Stolee via GitGitGadget, Jan 5, 2021
  31. 09/14 update-index: use add_index_entry()Derrick Stolee via GitGitGadget, Jan 5, 2021
  32. 12/14 update-index: reduce static globals, part 1Derrick Stolee via GitGitGadget, Jan 5, 2021
  33. 14/14 update-index: remove static globals from callbacksDerrick Stolee via GitGitGadget, Jan 5, 2021
  34. Eric SunshineJan 7, 2021
  35. Derrick StoleeJan 7, 2021
  36. Eric SunshineJan 7, 2021
  37. Junio C HamanoJan 7, 2021
  38. Derrick StoleeJan 8, 2021
  39. 10/14 update-index: replace several compatibility macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  40. 08/14 update-index: use remove_file_from_index()Derrick Stolee via GitGitGadget, Jan 5, 2021
  41. 06/14 update-index: use istate->cache_changedDerrick Stolee via GitGitGadget, Jan 5, 2021
  42. 13/14 update-index: reduce static globals, part 2Derrick Stolee via GitGitGadget, Jan 5, 2021
  43. 11/14 update-index: remove ce_match_stat(), all macrosDerrick Stolee via GitGitGadget, Jan 5, 2021
  44. 00/14 Remove more index compatibility macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  45. 01/14 mv: remove index compatibility macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  46. 02/14 rm: remove compatilibity macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  47. 04/14 update-index: use istate->cache over active_cacheDerrick Stolee via GitGitGadget, Jan 8, 2021
  48. 03/14 update-index: drop the_index, the_repositoryDerrick Stolee via GitGitGadget, Jan 8, 2021
  49. 12/14 update-index: reduce static globals, part 1Derrick Stolee via GitGitGadget, Jan 8, 2021
  50. 05/14 update-index: use istate->cache_nr over active_nrDerrick Stolee via GitGitGadget, Jan 8, 2021
  51. 07/14 update-index: use index_name_pos() over cache_name_pos()Derrick Stolee via GitGitGadget, Jan 8, 2021
  52. 09/14 update-index: use add_index_entry()Derrick Stolee via GitGitGadget, Jan 8, 2021
  53. 11/14 update-index: remove ce_match_stat(), all macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  54. 06/14 update-index: use istate->cache_changedDerrick Stolee via GitGitGadget, Jan 8, 2021
  55. 10/14 update-index: replace several compatibility macrosDerrick Stolee via GitGitGadget, Jan 8, 2021
  56. 08/14 update-index: use remove_file_from_index()Derrick Stolee via GitGitGadget, Jan 8, 2021
  57. 13/14 update-index: reduce static globals, part 2Derrick Stolee via GitGitGadget, Jan 8, 2021
  58. 14/14 update-index: remove static globals from callbacksDerrick Stolee via GitGitGadget, Jan 8, 2021
  59. Junio C HamanoJan 10, 2021
  60. Eric SunshineJan 10, 2021
  61. Derrick StoleeJan 10, 2021
  62. Derrick StoleeJan 25, 2021
  63. Junio C HamanoJan 6, 2021
  64. Derrick StoleeJan 6, 2021
  65. Junio C HamanoJan 6, 2021

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.