summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 46beb55)
raw | patch | inline | side by side (parent: 46beb55)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Mon, 21 Jul 2008 19:19:52 +0000 (21:19 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 26 Jul 2008 00:41:13 +0000 (17:41 -0700) |
We will need the command invocation path in system_path(). This path was
passed to setup_path(), but system_path() can be called earlier, for
example via:
main
commit_pager_choice
setup_pager
git_config
git_etc_gitconfig
system_path
Therefore, we introduce git_set_argv0_path() and call it as soon as
possible.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
passed to setup_path(), but system_path() can be called earlier, for
example via:
main
commit_pager_choice
setup_pager
git_config
git_etc_gitconfig
system_path
Therefore, we introduce git_set_argv0_path() and call it as soon as
possible.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
exec_cmd.c | patch | blob | history | |
exec_cmd.h | patch | blob | history | |
git.c | patch | blob | history | |
receive-pack.c | patch | blob | history | |
shell.c | patch | blob | history | |
upload-pack.c | patch | blob | history |
diff --git a/exec_cmd.c b/exec_cmd.c
index 8899e31b3b9edb528a339df394f891f76b8de594..dedb01da6f1b7e98edb0ce4459039f6825e024da 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
extern char **environ;
static const char *argv_exec_path;
+static const char *argv0_path;
static const char *builtin_exec_path(void)
{
return path;
}
+void git_set_argv0_path(const char *path)
+{
+ argv0_path = path;
+}
+
void git_set_argv_exec_path(const char *exec_path)
{
argv_exec_path = exec_path;
}
}
-void setup_path(const char *cmd_path)
+void setup_path(void)
{
const char *old_path = getenv("PATH");
struct strbuf new_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, cmd_path);
+ add_path(&new_path, argv0_path);
if (old_path)
strbuf_addstr(&new_path, old_path);
diff --git a/exec_cmd.h b/exec_cmd.h
index 7eb94e5e11c07dd269cf59fa5c85845c787d86dd..0c46cd5636e1bab445b91c6407210afcb5ccb772 100644 (file)
--- a/exec_cmd.h
+++ b/exec_cmd.h
#define GIT_EXEC_CMD_H
extern void git_set_argv_exec_path(const char *exec_path);
+extern void git_set_argv0_path(const char *path);
extern const char* git_exec_path(void);
-extern void setup_path(const char *);
+extern void setup_path(void);
extern int execv_git_cmd(const char **argv); /* NULL terminated */
extern int execl_git_cmd(const char *cmd, ...);
extern const char *system_path(const char *path);
index 1bfd271a711dc8b416fee8e4a8f0bfab3c52df3c..37b1d76a08ca59f3de54e11890dce962403cf8d3 100644 (file)
--- a/git.c
+++ b/git.c
{
const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
char *slash = (char *)cmd + strlen(cmd);
- const char *cmd_path = NULL;
int done_alias = 0;
/*
while (cmd <= slash && !is_dir_sep(*slash));
if (cmd <= slash) {
*slash++ = 0;
- cmd_path = cmd;
+ git_set_argv0_path(cmd);
cmd = slash;
}
* environment, and the $(gitexecdir) from the Makefile at build
* time.
*/
- setup_path(cmd_path);
+ setup_path();
while (1) {
/* See if it's an internal command */
diff --git a/receive-pack.c b/receive-pack.c
index fa653b49fe3c865b7e9c3723136b5b2344f8f4ca..d44c19e6b577023dcbaa188a0e67130ff4e5bd9a 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
if (!dir)
usage(receive_pack_usage);
- setup_path(NULL);
+ setup_path();
if (!enter_repo(dir, 0))
die("'%s': unable to chdir or not a git archive", dir);
index 91ca7de0827642fd949f861fca6991415853b1ce..6a48de05ff80f86050715ef3dab87a48b0a86ac9 100644 (file)
--- a/shell.c
+++ b/shell.c
{
const char *my_argv[4];
- setup_path(NULL);
+ setup_path();
if (!arg || !(arg = sq_dequote(arg)))
die("bad argument");
if (prefixcmp(me, "git-"))
if (!arg || strcmp(arg, "server"))
die("git-cvsserver only handles server: %s", arg);
- setup_path(NULL);
+ setup_path();
return execv_git_cmd(cvsserver_argv);
}
diff --git a/upload-pack.c b/upload-pack.c
index 9f82941f8b1e1cd65ebcd7675f7b7ba63c24acae..c911e70c9aa47b70dac41b7f4de2f0b4b6c1f948 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
if (i != argc-1)
usage(upload_pack_usage);
- setup_path(NULL);
+ setup_path();
dir = argv[i];