summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ce3ca27)
raw | patch | inline | side by side (parent: ce3ca27)
author | Alex Riesen <raa.lkml@gmail.com> | |
Thu, 1 Dec 2005 12:48:35 +0000 (13:48 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 2 Dec 2005 01:06:37 +0000 (17:06 -0800) |
- Use stderr for error output
- Build git_command more careful
- ENOENT is good enough for check of failed exec to show usage, no
access() check needed
[jc: Originally from Alex Riesen with inputs from Sven
Verdoolaege mixed in.]
Signed-off-by: Junio C Hamano <junkio@cox.net>
- Build git_command more careful
- ENOENT is good enough for check of failed exec to show usage, no
access() check needed
[jc: Originally from Alex Riesen with inputs from Sven
Verdoolaege mixed in.]
Signed-off-by: Junio C Hamano <junkio@cox.net>
git.c | patch | blob | history |
index 0b10b6e781fdf76a3822b15cfa304352aee812cc..878c359704dca8591755a68ff5a826503c017b3e 100644 (file)
--- a/git.c
+++ b/git.c
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;
}