|
1 | 1 | #include "cache.h" |
2 | 2 | #include "builtin.h" |
3 | 3 | #include "exec_cmd.h" |
| 4 | +#include "run-command.h" |
4 | 5 | #include "levenshtein.h" |
5 | 6 | #include "help.h" |
6 | 7 | #include "common-cmds.h" |
@@ -96,48 +97,6 @@ static void pretty_print_cmdnames(struct cmdnames *cmds, unsigned int colopts) |
96 | 97 | string_list_clear(&list, 0); |
97 | 98 | } |
98 | 99 |
|
99 | | -static int is_executable(const char *name) |
100 | | -{ |
101 | | - struct stat st; |
102 | | - |
103 | | - if (stat(name, &st) || /* stat, not lstat */ |
104 | | - !S_ISREG(st.st_mode)) |
105 | | - return 0; |
106 | | - |
107 | | -#if defined(GIT_WINDOWS_NATIVE) |
108 | | - /* |
109 | | - * On Windows there is no executable bit. The file extension |
110 | | - * indicates whether it can be run as an executable, and Git |
111 | | - * has special-handling to detect scripts and launch them |
112 | | - * through the indicated script interpreter. We test for the |
113 | | - * file extension first because virus scanners may make |
114 | | - * it quite expensive to open many files. |
115 | | - */ |
116 | | - if (ends_with(name, ".exe")) |
117 | | - return S_IXUSR; |
118 | | - |
119 | | -{ |
120 | | - /* |
121 | | - * Now that we know it does not have an executable extension, |
122 | | - * peek into the file instead. |
123 | | - */ |
124 | | - char buf[3] = { 0 }; |
125 | | - int n; |
126 | | - int fd = open(name, O_RDONLY); |
127 | | - st.st_mode &= ~S_IXUSR; |
128 | | - if (fd >= 0) { |
129 | | - n = read(fd, buf, 2); |
130 | | - if (n == 2) |
131 | | - /* look for a she-bang */ |
132 | | - if (!strcmp(buf, "#!")) |
133 | | - st.st_mode |= S_IXUSR; |
134 | | - close(fd); |
135 | | - } |
136 | | -} |
137 | | -#endif |
138 | | - return st.st_mode & S_IXUSR; |
139 | | -} |
140 | | - |
141 | 100 | static void list_commands_in_dir(struct cmdnames *cmds, |
142 | 101 | const char *path, |
143 | 102 | const char *prefix) |
|
0 commit comments