@@ -91,22 +91,32 @@ static int cygwin_stat(const char *path, struct stat *buf)
9191 * functions should be used. The choice is determined by core.ignorecygwinfstricks.
9292 * Reading this option is not always possible immediately as git_dir may be
9393 * not be set yet. So until it is set, use cygwin lstat/stat functions.
94+ * However, if the trust_executable_bit is set, we must use the Cygwin posix
95+ * stat/lstat as the Windows stat fuctions do not determine posix filemode.
9496 */
9597static int native_stat = 1 ;
98+ extern int trust_executable_bit ;
9699
97100static int git_cygwin_config (const char * var , const char * value , void * cb )
98101{
99- if (!strcmp (var , "core.ignorecygwinfstricks" ))
102+ if (!strcmp (var , "core.ignorecygwinfstricks" )) {
100103 native_stat = git_config_bool (var , value );
101- return 0 ;
104+ return 0 ;
105+ }
106+ return git_default_config (var , value , cb );
102107}
103108
104109static int init_stat (void )
105110{
106111 if (have_git_dir ()) {
107112 git_config (git_cygwin_config , NULL );
108- cygwin_stat_fn = native_stat ? cygwin_stat : stat ;
109- cygwin_lstat_fn = native_stat ? cygwin_lstat : lstat ;
113+ if (!trust_executable_bit && native_stat ) {
114+ cygwin_stat_fn = cygwin_stat ;
115+ cygwin_lstat_fn = cygwin_lstat ;
116+ } else {
117+ cygwin_stat_fn = stat ;
118+ cygwin_lstat_fn = lstat ;
119+ }
110120 return 0 ;
111121 }
112122 return 1 ;
0 commit comments