summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-30 02:16:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-30 02:16:41 (GMT)
commit7d5e13f652b4dfbf5e399dd2de32e5954368f0f8 (patch)
tree7c98cf40cd99bdf70aa2aa8de1f515147dbc94a3 /help.c
parent140921ca21f7ac35af07755e35205d6065b434be (diff)
parente3f43ce765c38f4be94239d07c8c3c596780c514 (diff)
downloadgit-7d5e13f652b4dfbf5e399dd2de32e5954368f0f8.zip
git-7d5e13f652b4dfbf5e399dd2de32e5954368f0f8.tar.gz
git-7d5e13f652b4dfbf5e399dd2de32e5954368f0f8.tar.bz2
Merge branch 'bw/forking-and-threading'
The "run-command" API implementation has been made more robust against dead-locking in a threaded environment. * bw/forking-and-threading: usage.c: drop set_error_handle() run-command: restrict PATH search to executable files run-command: expose is_executable function run-command: block signals between fork and execve run-command: add note about forking and threading run-command: handle dup2 and close errors in child run-command: eliminate calls to error handling functions in child run-command: don't die in child when duping /dev/null run-command: prepare child environment before forking string-list: add string_list_remove function run-command: use the async-signal-safe execv instead of execvp run-command: prepare command before forking t0061: run_command executes scripts without a #! line t5550: use write_script to generate post-update hook
Diffstat (limited to 'help.c')
-rw-r--r--help.c43
1 files changed, 1 insertions, 42 deletions
diff --git a/help.c b/help.c
index a07f01e..db7f3d7 100644
--- a/help.c
+++ b/help.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "builtin.h"
#include "exec_cmd.h"
+#include "run-command.h"
#include "levenshtein.h"
#include "help.h"
#include "common-cmds.h"
@@ -96,48 +97,6 @@ static void pretty_print_cmdnames(struct cmdnames *cmds, unsigned int colopts)
string_list_clear(&list, 0);
}
-static int is_executable(const char *name)
-{
- struct stat st;
-
- if (stat(name, &st) || /* stat, not lstat */
- !S_ISREG(st.st_mode))
- return 0;
-
-#if defined(GIT_WINDOWS_NATIVE)
- /*
- * On Windows there is no executable bit. The file extension
- * indicates whether it can be run as an executable, and Git
- * has special-handling to detect scripts and launch them
- * through the indicated script interpreter. We test for the
- * file extension first because virus scanners may make
- * it quite expensive to open many files.
- */
- if (ends_with(name, ".exe"))
- return S_IXUSR;
-
-{
- /*
- * Now that we know it does not have an executable extension,
- * peek into the file instead.
- */
- char buf[3] = { 0 };
- int n;
- int fd = open(name, O_RDONLY);
- st.st_mode &= ~S_IXUSR;
- if (fd >= 0) {
- n = read(fd, buf, 2);
- if (n == 2)
- /* look for a she-bang */
- if (!strcmp(buf, "#!"))
- st.st_mode |= S_IXUSR;
- close(fd);
- }
-}
-#endif
- return st.st_mode & S_IXUSR;
-}
-
static void list_commands_in_dir(struct cmdnames *cmds,
const char *path,
const char *prefix)