Back to Git
GSoC 2026

Refactoring in order to reduce Git’s global state

Git’s core C codebase still relies heavily on global state, such as the_repository and various environment-derived variables defined in environment.c. While this design was sufficient for a standalone CLI tool, it becomes problematic in more demanding scenarios. In particular, the reliance on implicit global state makes it difficult to safely embed Git as a library. Functions may read configuration or environment variables through global state, and in some cases call die(), which terminates the entire process. This behavior is incompatible with long-running or multi-threaded applications that need finer-grained control over error handling and repository isolation. Building upon the ongoing work from previous GSoC and Outreachy efforts, this project focuses on reducing such global dependencies by making state explicit. Where appropriate, repository-specific data will be passed through struct repository and related structures such as repo_settings or repo_config_values. Subsystem-specific variables will be localized to their respective domains instead of remaining globally accessible. By replacing implicit global assumptions with explicit data structure, this work aims to make Git’s internal APIs easier to reason about, safer to use in multi-repository contexts, and more suitable for long-term libification.

Project details

Contributor

Tian Yuchen

Mentors

Not available

Technologies

Not listed in the archive