Skip to content

Commit a472af8

Browse files
malon7782gitster
authored andcommitted
environment: use 'repo->initialized' for repo_protect_hfs() and repo_protect_ntfs()
To match how we refrain from calling repo_config_values() on an uninitialized instance of a repository object in other two topics that deal with ignore_case and trust_executable_bit, check the repo->initialized bit instead of the repo->gitdir member. 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 71386c2 commit a472af8

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

environment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ int is_bare_repository(void)
142142

143143
int repo_protect_ntfs(struct repository *repo)
144144
{
145-
return repo->gitdir ?
145+
return (repo && repo->initialized) ?
146146
repo_config_values(repo)->protect_ntfs :
147147
PROTECT_NTFS_DEFAULT;
148148
}
149149

150150
int repo_protect_hfs(struct repository *repo)
151151
{
152-
return repo->gitdir ?
152+
return (repo && repo->initialized) ?
153153
repo_config_values(repo)->protect_hfs :
154154
PROTECT_HFS_DEFAULT;
155155
}

environment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ int git_default_core_config(const char *var, const char *value,
127127

128128
/*
129129
* Getters for the `protect_hfs` and `protect_ntfs` fields of `struct repo_config_values`.
130-
* They check `repo->gitdir` to prevent calling repo_config_values()
131-
* before the configuration is loaded or in bare environments.
130+
* They check `repo->initialized` to prevent calling `repo_config_values()`
131+
* before the repository setup is fully complete or in non-git environments.
132132
*/
133133
int repo_protect_hfs(struct repository *repo);
134134
int repo_protect_ntfs(struct repository *repo);

0 commit comments

Comments
 (0)