aboutsummaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-12-03 23:46:02 -0800
committerJunio C Hamano <junkio@cox.net>2005-12-03 23:46:02 -0800
commit423325a2d24638ddcc82ce47be5e40be550f4507 (patch)
tree00960b001d786299d3da04a4467bd0c798bf8cda /git.c
parent93dcab2937624ebb97f91807576cddb242a55a46 (diff)
parentd79374c7b58d3814ffdc277de608243f8e665e3a (diff)
downloadgit-423325a2d24638ddcc82ce47be5e40be550f4507.tar.gz
git-423325a2d24638ddcc82ce47be5e40be550f4507.tar.xz
GIT 0.99.9l aka 1.0rc4v1.0rc4v0.99.9l
Diffstat (limited to 'git.c')
-rw-r--r--git.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/git.c b/git.c
index 0b10b6e78..619f25acf 100644
--- a/git.c
+++ b/git.c
@@ -13,6 +13,10 @@
# define PATH_MAX 4096
#endif
+#ifdef NO_SETENV
+extern int gitsetenv(char *name, char *value, int overwrite);
+#endif
+
static const char git_usage[] =
"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
@@ -283,16 +287,21 @@ int main(int argc, char **argv, char **envp)
len = strlen(git_command);
prepend_to_path(git_command, len);
- strncat(&git_command[len], "/git-", sizeof(git_command) - len);
- len += 5;
- strncat(&git_command[len], argv[i], sizeof(git_command) - len);
-
- if (access(git_command, X_OK))
- usage(exec_path, "'%s' is not a git-command", argv[i]);
+ len += snprintf(git_command + len, sizeof(git_command) - len,
+ "/git-%s", argv[i]);
+ if (sizeof(git_command) <= len) {
+ fprintf(stderr, "git: command name given is too long (%d)\n", len);
+ exit(1);
+ }
/* execve() can only ever return if it fails */
execve(git_command, &argv[i], envp);
- printf("Failed to run command '%s': %s\n", git_command, strerror(errno));
+
+ if (errno == ENOENT)
+ usage(exec_path, "'%s' is not a git-command", argv[i]);
+
+ fprintf(stderr, "Failed to run command '%s': %s\n",
+ git_command, strerror(errno));
return 1;
}