Skip to content

Commit 3f36e6f

Browse files
pranitbauva1997gitster
authored andcommitted
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 <[email protected]> Mentored by: Johannes Schindelin <[email protected]> Signed-off-by: Tanushree Tumane <[email protected]> Signed-off-by: Miriam Rubio <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fe973b commit 3f36e6f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

run-command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ static char *locate_in_PATH(const char *file)
210210
return NULL;
211211
}
212212

213-
static int exists_in_PATH(const char *file)
213+
int exists_in_PATH(const char *command)
214214
{
215-
char *r = locate_in_PATH(file);
215+
char *r = locate_in_PATH(command);
216216
int found = r != NULL;
217217
free(r);
218218
return found;

run-command.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ void child_process_clear(struct child_process *);
182182

183183
int is_executable(const char *name);
184184

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+
185197
/**
186198
* Start a sub-process. Takes a pointer to a `struct child_process`
187199
* that specifies the details and returns pipe FDs (if requested).

0 commit comments

Comments
 (0)