Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2005-12-01 15:48:35 +0300
committerJunio C Hamano <junkio@cox.net>2005-12-02 04:06:37 +0300
commit10b15b86f545e081aebba8783ad9e9acf6bf0d98 (patch)
tree2af70c2932f61b5a00f37e8799f98d6128905c13 /git.c
parentce3ca275452cf069eb6451d6f5b0f424a6f046aa (diff)
git wrapper: more careful argument stuffing
- 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>
Diffstat (limited to 'git.c')
-rw-r--r--git.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/git.c b/git.c
index 0b10b6e781..878c359704 100644
--- a/git.c
+++ b/git.c
@@ -283,16 +283,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;
}