run-command: make `exists_in_PATH()` non-static

Remove the `static` keyword from `exists_in_PATH()` function and declare the function in `run-command.h` file. The function will be used in bisect_visualize() in a later commit. Mentored by: Christian Couder <chriscool@tuxfamily.org> Mentored by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com> Signed-off-by: Miriam Rubio <mirucam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pranit Bauva committed Sep 13, 2021 at 19:39 UTC 3f36e6f30c5ee8d337dffa65c487080b87b29030
2 files changed +14 -2
run-command.c
+2 -2
@@ -210,9 +210,9 @@ static char *locate_in_PATH(const char *file)
210 return NULL;
211 }
212
213 -static int exists_in_PATH(const char *file)
213 +int exists_in_PATH(const char *command)
214 {
215 - char *r = locate_in_PATH(file);
215 + char *r = locate_in_PATH(command);
216 int found = r != NULL;
217 free(r);
218 return found;
run-command.h
+12
@@ -182,6 +182,18 @@ void child_process_clear(struct child_process *);
182
183 int is_executable(const char *name);
184
185 +/**
186 + * Check if the command exists on $PATH. This emulates the path search that
187 + * execvp would perform, without actually executing the command so it
188 + * can be used before fork() to prepare to run a command using
189 + * execve() or after execvp() to diagnose why it failed.
190 + *
191 + * The caller should ensure that command contains no directory separators.
192 + *
193 + * Returns 1 if it is found in $PATH or 0 if the command could not be found.
194 + */
195 +int exists_in_PATH(const char *command);
196 +
197 /**
198 * Start a sub-process. Takes a pointer to a `struct child_process`
199 * that specifies the details and returns pipe FDs (if requested).