summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a5d693)
raw | patch | inline | side by side (parent: 4a5d693)
author | Junio C Hamano <junkio@cox.net> | |
Sun, 5 Mar 2006 10:47:29 +0000 (02:47 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 5 Mar 2006 10:47:29 +0000 (02:47 -0800) |
Mark Wooding noticed there was a type mismatch warning in git.c; this
patch does things slightly differently (mostly tightening const) and
was what I was holding onto, waiting for the setup-revisions change
to be merged into the master branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
patch does things slightly differently (mostly tightening const) and
was what I was holding onto, waiting for the setup-revisions change
to be merged into the master branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
blame.c | patch | blob | history | |
exec_cmd.c | patch | blob | history | |
exec_cmd.h | patch | blob | history | |
git.c | patch | blob | history | |
receive-pack.c | patch | blob | history | |
run-command.c | patch | blob | history | |
run-command.h | patch | blob | history | |
send-pack.c | patch | blob | history | |
shell.c | patch | blob | history | |
upload-pack.c | patch | blob | history |
index 7308c36d232e362b64dcb5b2bc60fbe3014bdb28..562940ecedbd4f89aee89b9b4c96e8e2f21451df 100644 (file)
--- a/blame.c
+++ b/blame.c
}
}
+#if 0
/* For debugging only */
static void print_map(struct commit *cmit, struct commit *other)
{
printf("\n");
}
}
+#endif
// p is a patch from commit to other.
static void fill_line_map(struct commit *commit, struct commit *other,
diff --git a/exec_cmd.c b/exec_cmd.c
index b5e59a9ae9777183d3110defc2c8964aa0d8b62b..96cc2123b642173bbf7ff38cbea46695357b2c0b 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
}
-int execv_git_cmd(char **argv)
+int execv_git_cmd(const char **argv)
{
char git_command[PATH_MAX + 1];
- char *tmp;
int len, err, i;
const char *paths[] = { current_exec_path,
getenv("GIT_EXEC_PATH"),
for (i = 0; i < sizeof(paths)/sizeof(paths[0]); ++i) {
const char *exec_dir = paths[i];
+ const char *tmp;
+
if (!exec_dir) continue;
if (*exec_dir != '/') {
argv[0] = git_command;
/* execve() can only ever return if it fails */
- execve(git_command, argv, environ);
+ execve(git_command, (char **)argv, environ);
err = errno;
}
-int execl_git_cmd(char *cmd,...)
+int execl_git_cmd(const char *cmd,...)
{
int argc;
- char *argv[MAX_ARGS + 1];
- char *arg;
+ const char *argv[MAX_ARGS + 1];
+ const char *arg;
va_list param;
va_start(param, cmd);
diff --git a/exec_cmd.h b/exec_cmd.h
index 5150ee29f7a2bef5cd446dbb18de36c4ffa7cce8..989621ff4ecea463c340cb05eb035be0f7cb94a5 100644 (file)
--- a/exec_cmd.h
+++ b/exec_cmd.h
extern void git_set_exec_path(const char *exec_path);
extern const char* git_exec_path(void);
-extern int execv_git_cmd(char **argv); /* NULL terminated */
-extern int execl_git_cmd(char *cmd, ...);
+extern int execv_git_cmd(const char **argv); /* NULL terminated */
+extern int execl_git_cmd(const char *cmd, ...);
#endif /* __GIT_EXEC_CMD_H_ */
index a547dbd9136c70e49340814d1d57e92ec94c4c3d..164d3e9e4f41869192493d39e93ea4fc34fde4eb 100644 (file)
--- a/git.c
+++ b/git.c
setenv("PATH", path, 1);
}
-static void show_man_page(char *git_cmd)
+static void show_man_page(const char *git_cmd)
{
- char *page;
+ const char *page;
if (!strncmp(git_cmd, "git", 3))
page = git_cmd;
else {
int page_len = strlen(git_cmd) + 4;
-
- page = malloc(page_len + 1);
- strcpy(page, "git-");
- strcpy(page + 4, git_cmd);
- page[page_len] = 0;
+ char *p = malloc(page_len + 1);
+ strcpy(p, "git-");
+ strcpy(p + 4, git_cmd);
+ p[page_len] = 0;
+ page = p;
}
execlp("man", "man", page, NULL);
}
-static int cmd_version(int argc, char **argv, char **envp)
+static int cmd_version(int argc, const char **argv, char **envp)
{
printf("git version %s\n", GIT_VERSION);
return 0;
}
-static int cmd_help(int argc, char **argv, char **envp)
+static int cmd_help(int argc, const char **argv, char **envp)
{
- char *help_cmd = argv[1];
+ const char *help_cmd = argv[1];
if (!help_cmd)
cmd_usage(git_exec_path(), NULL);
show_man_page(help_cmd);
#define LOGSIZE (65536)
-static int cmd_log(int argc, char **argv, char **envp)
+static int cmd_log(int argc, const char **argv, char **envp)
{
struct rev_info rev;
struct commit *commit;
argc = setup_revisions(argc, argv, &rev, "HEAD");
while (1 < argc) {
- char *arg = argv[1];
+ const char *arg = argv[1];
if (!strncmp(arg, "--pretty", 8)) {
commit_format = get_commit_format(arg + 8);
if (commit_format == CMIT_FMT_ONELINE)
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-static void handle_internal_command(int argc, char **argv, char **envp)
+static void handle_internal_command(int argc, const char **argv, char **envp)
{
const char *cmd = argv[0];
static struct cmd_struct {
const char *cmd;
- int (*fn)(int, char **, char **);
+ int (*fn)(int, const char **, char **);
} commands[] = {
{ "version", cmd_version },
{ "help", cmd_help },
}
}
-int main(int argc, char **argv, char **envp)
+int main(int argc, const char **argv, char **envp)
{
- char *cmd = argv[0];
+ const char *cmd = argv[0];
char *slash = strrchr(cmd, '/');
char git_command[PATH_MAX + 1];
const char *exec_path = NULL;
diff --git a/receive-pack.c b/receive-pack.c
index 2a3db16d684e3d7ec9bbdd5f80266eb1e4af6f64..93929b5371bc0b9578ee5d3cb21c8ae6ade8cd1b 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
-static char *unpacker[] = { "unpack-objects", NULL };
+static const char *unpacker[] = { "unpack-objects", NULL };
static int report_status = 0;
{
struct command *cmd_p;
int argc;
- char **argv;
+ const char **argv;
if (access(update_post_hook, X_OK) < 0)
return;
argv[0] = update_post_hook;
for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
+ char *p;
if (cmd_p->error_string)
continue;
- argv[argc] = xmalloc(strlen(cmd_p->ref_name) + 1);
- strcpy(argv[argc], cmd_p->ref_name);
+ p = xmalloc(strlen(cmd_p->ref_name) + 1);
+ strcpy(p, cmd_p->ref_name);
+ argv[argc] = p;
argc++;
}
argv[argc] = NULL;
diff --git a/run-command.c b/run-command.c
index b3d287e97e7d13c1f8d4e8eab5c9af7359ccbc07..ca67ee9333e1f4125678fe607f44d75becc3cf7e 100644 (file)
--- a/run-command.c
+++ b/run-command.c
#include <sys/wait.h>
#include "exec_cmd.h"
-int run_command_v_opt(int argc, char **argv, int flags)
+int run_command_v_opt(int argc, const char **argv, int flags)
{
pid_t pid = fork();
}
}
-int run_command_v(int argc, char **argv)
+int run_command_v(int argc, const char **argv)
{
return run_command_v_opt(argc, argv, 0);
}
int run_command(const char *cmd, ...)
{
int argc;
- char *argv[MAX_RUN_COMMAND_ARGS];
+ const char *argv[MAX_RUN_COMMAND_ARGS];
const char *arg;
va_list param;
diff --git a/run-command.h b/run-command.h
index ef3ee053dee4e60db1887020c8ab8840027ff649..70b477a7483ce3a4997b20ee02223eeb483bde6c 100644 (file)
--- a/run-command.h
+++ b/run-command.h
#define RUN_COMMAND_NO_STDIO 1
#define RUN_GIT_CMD 2 /*If this is to be git sub-command */
-int run_command_v_opt(int argc, char **argv, int opt);
-int run_command_v(int argc, char **argv);
+int run_command_v_opt(int argc, const char **argv, int opt);
+int run_command_v(int argc, const char **argv);
int run_command(const char *cmd, ...);
#endif
diff --git a/send-pack.c b/send-pack.c
index f5583861433517527943dcefb3320e923fe634a0..c8ffc8d537d68e8296d8112582fd76e5148a9f98 100644 (file)
--- a/send-pack.c
+++ b/send-pack.c
static void exec_pack_objects(void)
{
- static char *args[] = {
+ static const char *args[] = {
"pack-objects",
"--stdout",
NULL
static void exec_rev_list(struct ref *refs)
{
struct ref *ref;
- static char *args[1000];
+ static const char *args[1000];
int i = 0, j;
args[i++] = "rev-list"; /* 0 */
index fc0c73cde7370801a0695befbf0e2610d2ea7ef1..8c08cf0fb339d293383c3dacb8cdfc805afa3727 100644 (file)
--- a/shell.c
+++ b/shell.c
my_argv[1] = arg;
my_argv[2] = NULL;
- return execv_git_cmd((char**) my_argv);
+ return execv_git_cmd(my_argv);
}
static struct commands {
diff --git a/upload-pack.c b/upload-pack.c
index 635abb371d4c86677f091551f731047b4ca08612..47560c9527b9c17db34f10e78d7c1f0d99b746e1 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
if (!pid) {
int i;
int args;
- char **argv;
+ const char **argv;
char *buf;
char **p;
}
else
args = nr_has + nr_needs + 5;
- argv = xmalloc(args * sizeof(char *));
+ p = xmalloc(args * sizeof(char *));
+ argv = (const char **) p;
buf = xmalloc(args * 45);
- p = argv;
dup2(fd[1], 1);
close(0);