MCPcopy Index your code
hub / github.com/git/git / sane_execvp

Function sane_execvp

run-command.c:232–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232int sane_execvp(const char *file, char * const argv[])
233{
234#ifndef GIT_WINDOWS_NATIVE
235 /*
236 * execvp() doesn't return, so we all we can do is tell trace2
237 * what we are about to do and let it leave a hint in the log
238 * (unless of course the execvp() fails).
239 *
240 * we skip this for Windows because the compat layer already
241 * has to emulate the execvp() call anyway.
242 */
243 int exec_id = trace2_exec(file, (const char **)argv);
244#endif
245
246 if (!execvp(file, argv))
247 return 0; /* cannot happen ;-) */
248
249#ifndef GIT_WINDOWS_NATIVE
250 {
251 int ec = errno;
252 trace2_exec_result(exec_id, ec);
253 errno = ec;
254 }
255#endif
256
257 /*
258 * When a command can't be found because one of the directories
259 * listed in $PATH is unsearchable, execvp reports EACCES, but
260 * careful usability testing (read: analysis of occasional bug
261 * reports) reveals that "No such file or directory" is more
262 * intuitive.
263 *
264 * We avoid commands with "/", because execvp will not do $PATH
265 * lookups in that case.
266 *
267 * The reassignment of EACCES to errno looks like a no-op below,
268 * but we need to protect against exists_in_PATH overwriting errno.
269 */
270 if (errno == EACCES && !strchr(file, '/'))
271 errno = exists_in_PATH(file) ? EACCES : ENOENT;
272 else if (errno == ENOTDIR && !strchr(file, '/'))
273 errno = ENOENT;
274 return -1;
275}
276
277char *git_shell_path(void)
278{

Callers 1

execv_git_cmdFunction · 0.85

Calls 1

exists_in_PATHFunction · 0.85

Tested by

no test coverage detected