index 878c359704dca8591755a68ff5a826503c017b3e..c26cac6555e940e1ae5573a99350388f09118b87 100644 (file)
--- a/git.c
+++ b/git.c
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include "git-compat-util.h"
#ifndef PATH_MAX
# define PATH_MAX 4096
#ifndef PATH_MAX
# define PATH_MAX 4096
}
#ifdef __GNUC__
}
#ifdef __GNUC__
-static void usage(const char *exec_path, const char *fmt, ...)
+static void cmd_usage(const char *exec_path, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3), __noreturn__));
#endif
__attribute__((__format__(__printf__, 2, 3), __noreturn__));
#endif
-static void usage(const char *exec_path, const char *fmt, ...)
+static void cmd_usage(const char *exec_path, const char *fmt, ...)
{
if (fmt) {
va_list ap;
{
if (fmt) {
va_list ap;
path_len = len + strlen(old_path) + 1;
path = malloc(path_len + 1);
path_len = len + strlen(old_path) + 1;
path = malloc(path_len + 1);
- path[path_len + 1] = '\0';
memcpy(path, dir, len);
path[len] = ':';
memcpy(path, dir, len);
path[len] = ':';
else if (!strcmp(arg, "help"))
show_help = 1;
else if (!show_help)
else if (!strcmp(arg, "help"))
show_help = 1;
else if (!show_help)
- usage(NULL, NULL);
+ cmd_usage(NULL, NULL);
}
if (i >= argc || show_help) {
if (i >= argc)
}
if (i >= argc || show_help) {
if (i >= argc)
- usage(exec_path, NULL);
+ cmd_usage(exec_path, NULL);
show_man_page(argv[i]);
}
show_man_page(argv[i]);
}
len += snprintf(git_command + len, sizeof(git_command) - len,
"/git-%s", argv[i]);
if (sizeof(git_command) <= len) {
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);
+ fprintf(stderr, "git: command name given is too long.\n");
exit(1);
}
exit(1);
}
execve(git_command, &argv[i], envp);
if (errno == ENOENT)
execve(git_command, &argv[i], envp);
if (errno == ENOENT)
- usage(exec_path, "'%s' is not a git-command", argv[i]);
+ cmd_usage(exec_path, "'%s' is not a git-command", argv[i]);
fprintf(stderr, "Failed to run command '%s': %s\n",
git_command, strerror(errno));
fprintf(stderr, "Failed to run command '%s': %s\n",
git_command, strerror(errno));