Re: Discuss GSOC: Refactoring in order to reduce Git’s global state
- From
Ayush Chandekar <ayu.chandekar@gmail.com>
- Date
- Mar 7, 2025, 15:44 UTC
- Message-ID
- <CAE7as+a+z9EgBnws-a4250TN_hDgWgapefxVAQHvpmUEfqKeTw@mail.gmail.com>
- In-Reply-To
- <Z8qpxj2i3vFjJe4l@pks.im>
Thanks for taking the time to respond!
Show 9 quoted lines
> Yeah, things depending on `startup_info` are definitely a more involved > thing to address, and I wouldn't necessarily recommend it for the > initial batch of refactorings. I'd recommend to rather focus on some of > the global variables we have in "environment.c" that store configuration > values, which are generally a bit easier to tackle. > > Also note that `local_repo_env[]` is nothing that we need to adapt. It > only stores a couple of environment variable names and does not have any > state, so it's perfectly fine to keep that variable.
Okay, got it.
Show 18 quoted lines
> It would be a bit more involved than a typical microproject, but I don't
> think it's particularly bad. It would involve a couple of steps:
>
> - Investigate all users of the `git_attributes_file` global variable
> and how they interact with the variable.
>
> - Adapt `git_attr_global_file()` so that it knows to not only handle
> the fallback value of `xdg_config_home("attributes")`, but also
> knows to first read the value from the config.
>
> - Adapt `git_attr_global_file()` so that it accepts a repository as
> parameter so that it doesn't need to depend on `the_repository`.
> This will also require you to adapt all callers.
>
> You _can_ use this as a microproject, but as said it's a bit more
> involved than what we'd expect. Which isn't necessarily bad if you
> manage to pull it off, but might make for a bit of a steep learning
> curve.I already submitted a patch quite a while ago: [1]. Thank you for clarifying how to approach this! It looks interesting to me, and I'd love to give it a try. I'll study more about it and hopefully submit a patch soon :)
Thanks, Ayush
[1]: https://lore.kernel.org/git/20250202120926.322417-1-ayu.chandekar@gmail.com/