{"thread":{"id":"64418","subject":"[Outreachy][Proposal v3]: Refactor in order to reduce Git’s global state","startedAt":"2025-11-01T19:08:30Z","lastAt":"2025-11-03T09:37:54Z","messageCount":4,"participants":["Bello Caleb Olamide","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"530064","messageId":"aQZaqG6t4F6XE0nt@ubuntu","threadId":"64418","inReplyTo":null,"subject":"[Outreachy][Proposal v3]: Refactor in order to reduce Git’s global state","fromName":"Bello Caleb Olamide","fromEmail":"belkid98@gmail.com","sentAt":"2025-11-01T19:08:24Z","receivedAt":"2025-11-01T19:08:30Z","isPatch":false,"sender":{"key":"belkid98@gmail.com","avatar":"https://avatars.githubusercontent.com/u/73387291?v=4"},"body":"Hello,\nThis is the third iteration on my proposal for the project\n\"Refactor in order to reduce Git’s global state\" for the 2025 Outreachy\nInternship program.\n\nThe change from v2 includes correction to the subject line to have the\ncorrect encoding on the mailing list.\n\nPersonal Bio:\n===========\nFull Name: Bello Caleb Olamide\nEmail: belkid98@gmail.com\nPersonal Blog: https://cloobtech.hashnode.dev/\nGitHub: https://github.com/cloobtech\n\nAbout Me:\n=========\nI'm Bello Olamide. I am passionate about software engineering and\nI love to figure out things. I like participating in tech\nevents such as hackathons but this will be my first open source experience\nand I have relished the opportunity and experience so far.\nI love being part of a community that strive to achieve a goal and one that\nI found myself is a small albeit growing community that helps to guide and\nmentor younger boys find their way into the tech ecosystem. I have developed\nmy coding skill via various sources including personal learning, freelancing,\ncollaboration with other developers and from the ALX Software Engineering\nprogram.\n\nPast Experience with Git:\n===================\nI have been a Git user for sometime now majorly for collaborating with other\ndevelopers, tracking version changes to files and during this contribution\nstage, I have understood the ropes of how to send patches to Git.\n\nContributions to the Git Community:\n==========================\nI have been able to send some patches to the Git codebase with the guidance\nand direction of community members.\n\nMicroproject:\n=============\nLink: https://lore.kernel.org/git/cover.1761217100.git.belkid98@gmail.com/\nBranch: ob/gpg-interface-cleanup\nStatus: Merged to master\nCommit ID: ce6d041635\nDescription: strbuf_split*() to split a string into multiple strbufs\nis often a wrong API to use.\nA few uses of it have been removed by simplifying the code.\n\nProject Overview\n================\nGit uses a single global `struct repository` object called `the_repository`\nwhich internal functions rely on to store, access and modify environment\nand configuration variables.\nWith this approach, multi-repository instances running in the same process\ncan lead to inconsistent behaviours and race conditions.\nBy refactoring the code to stop storing repository-scoped\nconfigurations in global variables in\n`environment.c file`, that is by moving the appropriate global\nvariables into localised state\nwithin the `struct repository` and `struct repo-settings`, the\ncodebase becomes more maintainable,\neasier to test and future work such as libifying Git becomes feasible.\n\nInternship Objectives and Plans\n========================\nThe project aims to identify repository scoped global variables in\n`environment.c` and related files that can be moved to local scope within\n`struct repository` and `struct repo-settings`, find an appropriate strategy\nto move them to local scope and implement the changes. This architectural\nimprovement will make the codebase more maintainable and enable better\nmulti-repository handling in the future.\n\nFrom a high level overview, environment.[ch] exposes some global\nvariables that reflect a per-repository state and examples of such include\ngit_work_tree_cfg, is_bare_repository_cfg, and core.* settings and functions\nwhich also depend on `the_repository` such as have_git_dir(),\nis_bare_repository().\n\nReview of Previous Work and Refactor Stategies:\n===============================================\nAfter a brief study of some related work done on the project,\nit is important to understand the purpose of the identified global variable\nand how it is used across the code base, observing how it relates with other\nsubsystems and moving it to the `struct repository` or `struct\nrepo-settings` if its use is repository specific, or specify an appropriate\ncontext based on its scopeand use this context in the accessor functions.\nFor example in [1], Patrick Steinhardt observes that `core.hooksPath`\nis repository specific and is stored in the global variable `git_hooks_path`.\nThe variable is then moved into local scope in the repo-settings\nstruct and a new accessor function `repo_settings_get_hooks_path()` is written\nand used to set the `hooks_path` of the repo specific struct which the path\nsubsystem reads from.\n\nSimilarly in [2], `core.sharedRepository` is tracked via the global variables\n`the_shared_repository ` and `need_shared_repository`. These are then\nmoved into the repo-settings struct, with new accessors functions\nwritten to modify them, and calls to the accessors in the path subsystem are\nthen modified to replace the old accessors which modify the global variables.\n\nThere were also cases where the functions were adapted to use exactly what it\nneeds down the call chain rather than writing new accessor functions.\nAn example is [3], where the global variable `the_hash_algo` is replaced with\nan explicit parameter `const struct git_hash_algo *algo` in low-level\nfunctions such as `static struct hashfile *hashfd_internal()` and the call\nsites adapted to use r->hash_algo or the_repository->hash_algo in places where\nthe subsystem has not gotten rid of `the_repository`.\nThis is also a strategy that can be used to replace global variables\n\n\nCompletion of Previous Unfinished Works\n---------------------------------------\nThere were also some pieces of work that were started but not finished which\nI plan to finish.\n1) [4] attempts to move the `git_attributes_file` global variable to the `struct repository`.\n   However because the global variable is used by the attributes subsystem and\n   a single repository can have more than one set of attributes, that is\n   the work-tree attributes and the index attributes, placing the variable into\n   a repository instance and passing it around in the call chain will not be\n   appropriate. Also most of the functions in the attributes subsystem pass the\n   `index_state` as a parameter and not the repository. This is because an index\n   knows its repository but a repository only knows its primary index.\n   Therefore each repository for an index will need to be known from the index.\n\n   As Junio pointed out in the discussion on the thread:\n   \"As the attribute system is all about giving extra information on the\n   paths that appear in the index and in the working tree, it may make\n   sense for the API to go from the index state which is about the\n   index and the working tree to access the attributes, rather than\n   from the repository structure, which controls a lot wider concept\n   and moving anything and everything there will easily and quickly\n   make it a messy kitchen sink.\"\n\n   So Given that the `index_state` struct has a repo member, we can move\n   'git_attributes_file' into the repo struct but access it through the\n   `index_state`. By doing that we know the index truly owns the attributes.\n\n2) There is also `is_bare_repository_cfg` as seen in [5].\n   I have only skimmed through the discussions and patches to understand why it\n   was not finished.\n   But I will do an in depth study to understand why it was not completed and what\n   it takes to finish it.\n\n\nProposed Project Execution Timeline\n===================================\n\n1. Study Code Base To Identify Suitable Candidates (Now - December 8, 2025):\n------------------------------------------------------------------------\n- The first step will be familiarising myself with the code base to\n   understand how these global variables in environment.c are initialised,\n   used and how they interact with other subsystems.\n\n2. Community Feedback Bonding ( December 9 - December 15, 2025):\n------------------------------------------------------------\n- Discuss environment variables with mentors and community members\n- Understand best refactoring approach based on feedback from mentors\n\n3. Review Existing Patch and Define Criteria (December 16 - January 9, 2026):\n-------------------------------------------------------------\n- Thoroughly examine the existing patch series submitted to the mailing\n    list  to understand;\n    * What criteria makes a global variable a suitable candidate to be\n       moved to the `struct repository` or `struct repo-settings`\n    * What appropriate context it should be moved into based on its\n       interactions with other subsystems.\n    * If remaining a global variable is the best approach in its case.\n- This information can be gotten by paying attention to the discussions\n  in the patches and also engaging with my mentors and the Git community.\n\nTo buttress the above points from my brief study of previous work,\nif the variable value is:\ni. meant to be different for different repositories, it is a candidate to move,\n   if not then it is left as is, like the case of `local_repo_env[]`.\n\nii. used during early startup, it cannot be moved blindly but will need\n    a closer inspection and refactoring of the startup code as is the case with\n    `have_git_dir()` noted by Patrick and Shejialuo in [7].\n\nIts relationship with other subsystems is also a criteria to define\nsuch as the case of `git_attributes_file mentioned` above\n\n4. Implement Candidates and Submit PRs ( January 10 - February 28, 2026):\n--------------------------------------------------------------------------\n- With collaboration from mentors and the Git community, identify\n  suitable candidates for relocation.\n- Relocate them into `struct repository`, `struct repo-settings` and\n  other appropriate contexts.\n- Pass the repository parameter to accessor functions to replace the\n  global dependence\n- Write new accessor functions if necessary else pass context directly to\n  functions.\n- Modify accessor callers to reflect the new changes while ensuring\n  all affected code paths works correctly\n- Update tests and documentations\n- Recursively submit patches for reviews, engaging in discussions and\n  implement suggestions\n\n5. Final Report on Project (February 29 - March 6)\n--------------------------------\n- Document final report in my blog with details on my experience\n- Finalize any pending tasks or reviews on any submitted patch\n\nAvailability\n============\nI am currently not enrolled in any school or jobs, so I will be able to give\n30 hours a week or more to make the project a success.\n\nBlogging\n=========\nI have set up my blog where I will document my progress, insights,\nchallenges and experience weekly.\n\nPost Outreachy\n==============\nThe welcoming and patient atmosphere during this short contribution\nperiod with the Git\ncommunity has made me want to keep getting involved with the\ncommunity. I am committed to\ncontinuously contributing to Git and become a part of of the next set\nof contributors\nto champion the continuous development of Git.\n\nAppreciation\n============\nTo Junio and Christian, I really appreciate your guidance, patience\nand direction while\nreviewing and helping with my patches and to Usman for your inputs and to every\nmember of the Git community, I thank you all.\n\nReferences\n==========\n[1]: https://public-inbox.org/git/20250207-b4-pks-path-drop-the-repository-v2-14-13cad3c11b8a@pks.im/#Z31config.c\n[2]: https://public-inbox.org/git/20250206-b4-pks-path-drop-the-repository-v1-15-4e77f0313206@pks.im/\n[3]: https://public-inbox.org/git/20250306-b4-pks-objects-without-the-repository-v2-1-f3465327be69@pks.im/#Z31csum-file.h\n[4]: https://lore.kernel.org/git/20250309153321.254844-1-ayu.chandekar@gmail.com/\n[5]: https://public-inbox.org/git/pull.1826.git.git.1730926082.gitgitgadget@gmail.com/\n[6]: https://lore.kernel.org/git/d0e2042b3061320fac8a8fdf9043c6ab4dbed5a2.1752882401.git.ayu.chandekar@gmail.com/\n[7]: https://lore.kernel.org/git/c82620a1f54ea6760bff204fd2b5fe5c2df1896c.1753804956.git.ayu.chandekar@gmail.com/\n"},{"id":"530110","messageId":"CAP8UFD3TdUb9RBktdxwA7Qj=6Oxqpzg-ZrVP5eT_+38TPE+n-A@mail.gmail.com","threadId":"64418","inReplyTo":"aQZaqG6t4F6XE0nt@ubuntu","subject":"Re: [Outreachy][Proposal v3]: Refactor in order to reduce Git’s global state","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2025-11-03T07:52:19Z","receivedAt":"2025-11-03T07:52:33Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Sat, Nov 1, 2025 at 8:08 PM Bello Caleb Olamide <belkid98@gmail.com> wrote:\n>\n> Hello,\n> This is the third iteration on my proposal for the project\n> \"Refactor in order to reduce Git’s global state\" for the 2025 Outreachy\n> Internship program.\n>\n> The change from v2 includes correction to the subject line to have the\n> correct encoding on the mailing list.\n\nThanks for iterating on your proposal.\n\nPlease make sure you properly submit it to Outreachy though. It looks\nlike you haven't submitted it yet, while the deadline is today at 4PM\nUTC, so you don't have much time left.\n\nI will try to take another look, but I am not sure I will have time to\ndo it before the deadline today. So don't wait for it before\nsubmitting.\n\nThanks.\n"},{"id":"530111","messageId":"CAP8UFD0yamBJQHT8eh1=u9-m2f80K9FM21nozB6paPpEJrP5wA@mail.gmail.com","threadId":"64418","inReplyTo":"CAP8UFD3TdUb9RBktdxwA7Qj=6Oxqpzg-ZrVP5eT_+38TPE+n-A@mail.gmail.com","subject":"Re: [Outreachy][Proposal v3]: Refactor in order to reduce Git’s global state","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2025-11-03T07:58:36Z","receivedAt":"2025-11-03T07:58:49Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"(There is a \"Reply-to: 20251030144934.9689-1-belkid98@gmail.com\"\nheader in the email you sent, but that email address doesn't work. So\nI am resending to Bello Caleb Olamide <belkid98@gmail.com>.)\n\nHi,\n\nOn Sat, Nov 1, 2025 at 8:08 PM Bello Caleb Olamide <belkid98@gmail.com> wrote:\n>\n> Hello,\n> This is the third iteration on my proposal for the project\n> \"Refactor in order to reduce Git’s global state\" for the 2025 Outreachy\n> Internship program.\n>\n> The change from v2 includes correction to the subject line to have the\n> correct encoding on the mailing list.\n\nThanks for iterating on your proposal.\n\nPlease make sure you properly submit it to Outreachy though. It looks\nlike you haven't submitted it yet, while the deadline is today at 4PM\nUTC, so you don't have much time left.\n\nI will try to take another look, but I am not sure I will have time to\ndo it before the deadline today. So don't wait for it before\nsubmitting.\n\nThanks.\n"},{"id":"530113","messageId":"aQh3Ic+iXsiqMo4D@ubuntu","threadId":"64418","inReplyTo":"CAP8UFD0yamBJQHT8eh1=u9-m2f80K9FM21nozB6paPpEJrP5wA@mail.gmail.com","subject":"Re: [Outreachy][Proposal v3]: Refactor in order to reduce Git’s global state","fromName":"Bello Caleb Olamide","fromEmail":"belkid98@gmail.com","sentAt":"2025-11-03T09:37:12Z","receivedAt":"2025-11-03T09:37:54Z","isPatch":false,"sender":{"key":"belkid98@gmail.com","avatar":"https://avatars.githubusercontent.com/u/73387291?v=4"},"body":"On Mon, Nov 03, 2025 at 08:58:36AM +0100, Christian Couder wrote:\n> (There is a \"Reply-to: 20251030144934.9689-1-belkid98@gmail.com\"\n> header in the email you sent, but that email address doesn't work. So\n> I am resending to Bello Caleb Olamide <belkid98@gmail.com>.)\n\nThank you very much.\n\n>\n> Hi,\n>\n> On Sat, Nov 1, 2025 at 8:08 PM Bello Caleb Olamide <belkid98@gmail.com> wrote:\n> >\n> > Hello,\n> > This is the third iteration on my proposal for the project\n> > \"Refactor in order to reduce Git’s global state\" for the 2025 Outreachy\n> > Internship program.\n> >\n> > The change from v2 includes correction to the subject line to have the\n> > correct encoding on the mailing list.\n> \n> Thanks for iterating on your proposal.\n> \n> Please make sure you properly submit it to Outreachy though. It looks\n> like you haven't submitted it yet, while the deadline is today at 4PM\n> UTC, so you don't have much time left.\n\nThank you very much Christian.\nI have successfully submitted it to Outreachy.\n\n> \n> I will try to take another look, but I am not sure I will have time to\n> do it before the deadline today. So don't wait for it before\n> submitting.\n\nOkay, I will be expecting further feedbacks from you.\n\nThanks\n\n> \n> Thanks.\n\n"}]}