File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,16 +105,25 @@ static int is_executable(const char *name)
105105 return 0 ;
106106
107107#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 */
109118 char buf [3 ] = { 0 };
110119 int n ;
111120 int fd = open (name , O_RDONLY );
112121 st .st_mode &= ~S_IXUSR ;
113122 if (fd >= 0 ) {
114123 n = read (fd , buf , 2 );
115124 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 , "#!" ))
118127 st .st_mode |= S_IXUSR ;
119128 close (fd );
120129 }
You can’t perform that action at this time.
0 commit comments