summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-12-05 11:54:29 -0800
committerJunio C Hamano <junkio@cox.net>2005-12-05 15:50:29 -0800
commit4050c0df8ec7043315e2192695de432875239775 (patch)
tree36ea762082320aae037a95157c6c7f0ffc383046 /git.c
parentcd8c4589473d2a6669cf882ebcd708a2d81e9168 (diff)
downloadgit-4050c0df8ec7043315e2192695de432875239775.tar.gz
Clean up compatibility definitions.
This attempts to clean up the way various compatibility functions are defined and used. - A new header file, git-compat-util.h, is introduced. This looks at various NO_XXX and does necessary function name replacements, equivalent of -Dstrcasestr=gitstrcasestr in the Makefile. - Those function name replacements are removed from the Makefile. - Common features such as usage(), die(), xmalloc() are moved from cache.h to git-compat-util.h; cache.h includes git-compat-util.h itself. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git.c')
-rw-r--r--git.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/git.c b/git.c
index ee5048aaaa..c26cac6555 100644
--- a/git.c
+++ b/git.c
@@ -8,15 +8,12 @@
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include "git-compat-util.h"
#ifndef PATH_MAX
# define PATH_MAX 4096
#endif
-#ifdef NO_SETENV
-extern int gitsetenv(const char *, const char *, int);
-#endif
-
static const char git_usage[] =
"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
@@ -156,10 +153,10 @@ static void list_commands(const char *exec_path, const char *pattern)
}
#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
-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;
@@ -254,12 +251,12 @@ int main(int argc, char **argv, char **envp)
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)
- usage(exec_path, NULL);
+ cmd_usage(exec_path, NULL);
show_man_page(argv[i]);
}
@@ -297,7 +294,7 @@ int main(int argc, char **argv, char **envp)
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));