git-send-email: Read the default SMTP server from the GIT config file
[gitweb.git] / fetch.c
diff --git a/fetch.c b/fetch.c
index 2151c7b78c34f06f38f538f155169a0501c2ff54..34df8d37d7dc92f8b652c160c49f4ace6e44e19c 100644 (file)
--- a/fetch.c
+++ b/fetch.c
@@ -84,7 +84,7 @@ static int process_commit(struct commit *commit)
        if (commit->object.flags & COMPLETE)
                return 0;
 
-       memcpy(current_commit_sha1, commit->object.sha1, 20);
+       hashcpy(current_commit_sha1, commit->object.sha1);
 
        pull_say("walk %s\n", sha1_to_hex(commit->object.sha1));
 
@@ -234,8 +234,8 @@ int pull_targets_stdin(char ***target, const char ***write_ref)
                        *target = xrealloc(*target, targets_alloc * sizeof(**target));
                        *write_ref = xrealloc(*write_ref, targets_alloc * sizeof(**write_ref));
                }
-               (*target)[targets] = strdup(tg_one);
-               (*write_ref)[targets] = rf_one ? strdup(rf_one) : NULL;
+               (*target)[targets] = xstrdup(tg_one);
+               (*write_ref)[targets] = rf_one ? xstrdup(rf_one) : NULL;
                targets++;
        }
        return targets;
@@ -245,7 +245,7 @@ void pull_targets_free(int targets, char **target, const char **write_ref)
 {
        while (targets--) {
                free(target[targets]);
-               if (write_ref[targets])
+               if (write_ref && write_ref[targets])
                        free((char *) write_ref[targets]);
        }
 }
@@ -263,7 +263,7 @@ int pull(int targets, char **target, const char **write_ref,
        track_object_refs = 0;
 
        for (i = 0; i < targets; i++) {
-               if (!write_ref[i])
+               if (!write_ref || !write_ref[i])
                        continue;
 
                lock[i] = lock_ref_sha1(write_ref[i], NULL, 0);
@@ -295,15 +295,14 @@ int pull(int targets, char **target, const char **write_ref,
                msg = NULL;
        }
        for (i = 0; i < targets; i++) {
-               if (!write_ref[i])
+               if (!write_ref || !write_ref[i])
                        continue;
                ret = write_ref_sha1(lock[i], &sha1[20 * i], msg ? msg : "fetch (unknown)");
                lock[i] = NULL;
                if (ret)
                        goto unlock_and_fail;
        }
-       if (msg)
-               free(msg);
+       free(msg);
 
        return 0;