Merge branch 'gl/cleanup'
[gitweb.git] / receive-pack.c
index eae31e370d44988b9a8ee9ddb6c3191b4f18bf3e..201531626c2a60dffd1720ab4d00d7023bcbc78e 100644 (file)
@@ -6,12 +6,12 @@
 
 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;
+static int report_status;
 
 static char capabilities[] = "report-status";
-static int capabilities_sent = 0;
+static int capabilities_sent;
 
 static int show_ref(const char *path, const unsigned char *sha1)
 {
@@ -40,7 +40,7 @@ struct command {
        char ref_name[FLEX_ARRAY]; /* more */
 };
 
-static struct command *commands = NULL;
+static struct command *commands;
 
 static int is_all_zeroes(const char *hex)
 {
@@ -92,7 +92,7 @@ static int run_update_hook(const char *refname,
        case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
                return error("waitpid is confused");
        case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
-               return error("%s died of signal\n", update_hook);
+               return error("%s died of signal", update_hook);
        case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
                return error("%s died strangely", update_hook);
        default:
@@ -158,7 +158,7 @@ static int update(struct command *cmd)
        if (run_update_hook(name, old_hex, new_hex)) {
                unlink(lock_name);
                cmd->error_string = "hook declined";
-               return error("hook declined to update %s\n", name);
+               return error("hook declined to update %s", name);
        }
        else if (rename(lock_name, name) < 0) {
                unlink(lock_name);
@@ -177,7 +177,7 @@ static void run_update_post_hook(struct command *cmd)
 {
        struct command *cmd_p;
        int argc;
-       char **argv;
+       const char **argv;
 
        if (access(update_post_hook, X_OK) < 0)
                return;
@@ -190,10 +190,12 @@ static void run_update_post_hook(struct command *cmd)
        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;
@@ -245,8 +247,8 @@ static void read_head_info(void)
                                report_status = 1;
                }
                cmd = xmalloc(sizeof(struct command) + len - 80);
-               memcpy(cmd->old_sha1, old_sha1, 20);
-               memcpy(cmd->new_sha1, new_sha1, 20);
+               hashcpy(cmd->old_sha1, old_sha1);
+               hashcpy(cmd->new_sha1, new_sha1);
                memcpy(cmd->ref_name, line + 82, len - 81);
                cmd->error_string = "n/a (unpacker error)";
                cmd->next = NULL;