File tree 1 file changed +12
-3
lines changed 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -107,16 +107,25 @@ static int is_executable(const char *name)
107
107
return 0 ;
108
108
109
109
#if defined(GIT_WINDOWS_NATIVE )
110
- { /* cannot trust the executable bit, peek into the file instead */
110
+ /* On Windows we cannot use the executable bit. The executable
111
+ * state is determined by extension only. We do this first
112
+ * because with virus scanners opening an executeable for
113
+ * reading is potentially expensive.
114
+ */
115
+ if (ends_with (name , ".exe" ))
116
+ return S_IXUSR ;
117
+
118
+ { /* now that we know it does not have an executable extension,
119
+ peek into the file instead */
111
120
char buf [3 ] = { 0 };
112
121
int n ;
113
122
int fd = open (name , O_RDONLY );
114
123
st .st_mode &= ~S_IXUSR ;
115
124
if (fd >= 0 ) {
116
125
n = read (fd , buf , 2 );
117
126
if (n == 2 )
118
- /* DOS executables start with "MZ" */
119
- if (!strcmp (buf , "#!" ) || ! strcmp ( buf , "MZ" ) )
127
+ /* look for a she-bang */
128
+ if (!strcmp (buf , "#!" ))
120
129
st .st_mode |= S_IXUSR ;
121
130
close (fd );
122
131
}
You can’t perform that action at this time.
0 commit comments