Skip to content

Commit

Permalink
Turn builtin_exec_path into a function.
Browse files Browse the repository at this point in the history
builtin_exec_path returns the hard-coded installation path, which is used
as the ultimate fallback to look for git commands. Making it into a function
enables us in a follow-up patch to return a computed value instead of just
a constant string.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
  • Loading branch information
Johannes Sixt committed Jun 26, 2008
1 parent fc2ded5 commit 4ec22a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
#define MAX_ARGS 32

extern char **environ;
static const char *builtin_exec_path = GIT_EXEC_PATH;
static const char *argv_exec_path;

static const char *builtin_exec_path(void)
{
return GIT_EXEC_PATH;
}

void git_set_argv_exec_path(const char *exec_path)
{
argv_exec_path = exec_path;
Expand All @@ -26,7 +30,7 @@ const char *git_exec_path(void)
return env;
}

return builtin_exec_path;
return builtin_exec_path();
}

static void add_path(struct strbuf *out, const char *path)
Expand All @@ -50,7 +54,7 @@ void setup_path(const char *cmd_path)

add_path(&new_path, argv_exec_path);
add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
add_path(&new_path, builtin_exec_path);
add_path(&new_path, builtin_exec_path());
add_path(&new_path, cmd_path);

if (old_path)
Expand Down

0 comments on commit 4ec22a4

Please sign in to comment.