environment: migrate trust_executable_bit (test)#2316
Conversation
|
There is an issue in commit 87e5acf:
|
7207106 to
d2f2b49
Compare
|
It looks like in the description and commit messages |
|
The commit title |
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". 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>
d2f2b49 to
2fb2eff
Compare
Move the global 'trust_executable_bit' configuration into the repository-specific 'repo_config_values' struct. For now, associated functions in read-cache.c 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>
In the previous commit, the gloabl 'trust_executable_bit' was migrated into 'repo_config_values', but low-level helpers in read-cache.c still relied on 'the_repository' to access it. Refactor the signatures of ce_mode_from_stat(), st_mode_from_ce(), fake_lstat(), and check_removed() to accept a 'struct index_state *istate'. This allows these functions to retrieve the repository context via 'istate->repo'. 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>
2fb2eff to
f02c007
Compare
|
It seems to me that the goal of the "read-cache: pass 'istate' to stat/mode helper functions" is to help with getting rid of I think saying something like "This is a step in the long term direction of getting rid of In the commit message you might also want to take into account what I said in this comment: |
|
I am not sure why the description doesn't also mention: https://lore.kernel.org/git/20260301190017.53539-1-dronarajgyawali@gmail.com/ I also think it would be nice if there was a small explanation of what the previous works on this tried and why they weren't successful. |
There was a problem hiding this comment.
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".
Specified the wrong range when replacing quotes via Vim, which has resulted in inconsistent quote types in the filenames here.
"read-cache.c" vs 'read-cache.h'
How did I miss it? :((
The 'core.filemode' configuration, which is stored as a global variable 'trust_executable_bit', is a core filesystem capability flag.
Move it into '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.
To avoid falling back to 'the_repository', refactor the signatures of helper functions:
These functions now accept a 'struct index_state *istate', ensuring the correct context is seamlessly passed down to the lowest levels.
Note: 'repo_config_values()' still does not support any 'struct repository' other than 'the_repository'. In other words, this series of patches is laying the groundwork for the eventual elimination of 'the_repository'.
Previous related work:
[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