@@ -56,12 +56,16 @@ int git_attr_get(
5656 git_attr_file * file ;
5757 git_attr_name attr ;
5858 git_attr_rule * rule ;
59+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN ;
5960
6061 assert (value && repo && name );
6162
6263 * value = NULL ;
6364
64- if (git_attr_path__init (& path , pathname , git_repository_workdir (repo ), GIT_DIR_FLAG_UNKNOWN ) < 0 )
65+ if (git_repository_is_bare (repo ))
66+ dir_flag = GIT_DIR_FLAG_FALSE ;
67+
68+ if (git_attr_path__init (& path , pathname , git_repository_workdir (repo ), dir_flag ) < 0 )
6569 return -1 ;
6670
6771 if ((error = collect_attr_files (repo , NULL , flags , pathname , & files )) < 0 )
@@ -114,13 +118,17 @@ int git_attr_get_many_with_session(
114118 git_attr_rule * rule ;
115119 attr_get_many_info * info = NULL ;
116120 size_t num_found = 0 ;
121+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN ;
117122
118123 if (!num_attr )
119124 return 0 ;
120125
121126 assert (values && repo && names );
122127
123- if (git_attr_path__init (& path , pathname , git_repository_workdir (repo ), GIT_DIR_FLAG_UNKNOWN ) < 0 )
128+ if (git_repository_is_bare (repo ))
129+ dir_flag = GIT_DIR_FLAG_FALSE ;
130+
131+ if (git_attr_path__init (& path , pathname , git_repository_workdir (repo ), dir_flag ) < 0 )
124132 return -1 ;
125133
126134 if ((error = collect_attr_files (repo , attr_session , flags , pathname , & files )) < 0 )
@@ -196,10 +204,14 @@ int git_attr_foreach(
196204 git_attr_rule * rule ;
197205 git_attr_assignment * assign ;
198206 git_strmap * seen = NULL ;
207+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN ;
199208
200209 assert (repo && callback );
201210
202- if (git_attr_path__init (& path , pathname , git_repository_workdir (repo ), GIT_DIR_FLAG_UNKNOWN ) < 0 )
211+ if (git_repository_is_bare (repo ))
212+ dir_flag = GIT_DIR_FLAG_FALSE ;
213+
214+ if (git_attr_path__init (& path , pathname , git_repository_workdir (repo ), dir_flag ) < 0 )
203215 return -1 ;
204216
205217 if ((error = collect_attr_files (repo , NULL , flags , pathname , & files )) < 0 ||
0 commit comments