environment.c: migrate 'trust_executable_bit' into 'repo_config_values'#1
Open
malon7782 wants to merge 3 commits into
Open
environment.c: migrate 'trust_executable_bit' into 'repo_config_values'#1malon7782 wants to merge 3 commits into
malon7782 wants to merge 3 commits into
Conversation
The 'read-cache.c' file already includes 'environment.h', which provides the extern declarations for variables like 'trust_executable_bit' and 'has_symlinks'. Remove the redundant extern declarations inside 'st_mode_from_ce()' to clean up the code. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com> Mentored-by: Olamide Caleb Bello <belkid98@gmail.com> Signed-off-by: Tian Yuchen <cat@malon.dev>
The ce_mode_from_stat() function is declared as a static inline function in 'read-cache.h'. As we want to migrate configuration variables, this helper function will need access to corresponding repository-specific configuration logic. Move the implementation to 'read-cache.c' to cleanly encapsulate its dependencies. Note that the 'extern int trust_executable_bit, has_symlinks;' line is discarded because it's not necessary when the function lives in "read-cache.c". At present, this change has no visible impact, but it is crucial for our future plans to pass in the repo context. Comment has been added whilst we are at it. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com> Mentored-by: Olamide Caleb Bello <belkid98@gmail.com> Signed-off-by: Tian Yuchen <cat@malon.dev>
Move the global 'trust_executable_bit' configurations into the repository-specific 'repo_config_values' struct. To ensure code readability, the getter functions 'repo_trust_executable_bit()' has been introduced. For now, associated functions access this configuration by explicitly falling back to 'the_repository'. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com> Mentored-by: Olamide Caleb Bello <belkid98@gmail.com> Signed-off-by: Tian Yuchen <cat@malon.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 'core.filemode' (stored as 'trust_executable_bit') configuration act as a core filesystem capability flag.
This series moves it into 'struct repo_config_values' to tie it to the specific repository instance it was read from. Eager parsing is maintained because this flag is heavily consulted in hot paths.
Note: 'repo_config_values()' still does not support any struct repository other than the_repository due to how deeply these flags are accessed. In other words, this series of patches is laying the groundwork for the eventual elimination of the_repository.
Previous related work:
[PATCH 2/6] config: add trust_executable_bit to global config [1]
[PATCH] Refactor 'trust_executable_bit' to repository-scoped setting [2]
(This previous attempt was unsuccessful because the target location selected was 'struct repo_settings', which our analysis indicated was not the optimal choice. For further details, please see: [3])
Changes since V1:
Dropped istate plumbing: Dropped the last commit ("read-cache: pass 'istate' to stat/mode helper functions") to keep the patch focused.
Introduced safe getter: Getter functions ('repo_trust_executable_bit()') have been introduced to retrieve configuration values safely.
Added comments for 'ce_mode_from_stat()'.
Thanks!
[1] https://lore.kernel.org/git/837b5360b40f992351f489a0ae05fedf49884c6e.1685716420.git.gitgitgadget@gmail.com/
[2] https://lore.kernel.org/git/20260301190017.53539-1-dronarajgyawali@gmail.com/
[3] https://lore.kernel.org/git/xmqq1pht6nyx.fsf@gitster.g/
Mentored-by: Christian Couder christian.couder@gmail.com
Mentored-by: Ayush Chandekar ayu.chandekar@gmail.com
Mentored-by: Olamide Caleb Bello belkid98@gmail.com
Signed-off-by: Tian Yuchen cat@malon.dev