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