Teach rev-list an option to read revs from the standard input.
[gitweb.git] / send-pack.c
index f7c0cfc6f67ba4d325ac6fc9f6c74fad78d1208e..ac4501d34154301030cf98ff122eb233095417b7 100644 (file)
@@ -53,7 +53,7 @@ static void exec_rev_list(struct ref *refs)
                if (900 < i)
                        die("git-rev-list environment overflow");
                if (!is_zero_sha1(ref->new_sha1)) {
-                       char *buf = malloc(100);
+                       char *buf = xmalloc(100);
                        args[i++] = buf;
                        snprintf(buf, 50, "%s", sha1_to_hex(ref->new_sha1));
                        buf += 50;
@@ -75,7 +75,7 @@ static void exec_rev_list(struct ref *refs)
                if (is_zero_sha1(ref->new_sha1) &&
                    !is_zero_sha1(ref->old_sha1) &&
                    has_sha1_file(ref->old_sha1)) {
-                       char *buf = malloc(42);
+                       char *buf = xmalloc(42);
                        args[i++] = buf;
                        snprintf(buf, 42, "^%s", sha1_to_hex(ref->old_sha1));
                }
@@ -185,7 +185,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1)
        struct ref *ref;
        int len = strlen(refname) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
-       memcpy(ref->new_sha1, sha1, 20);
+       hashcpy(ref->new_sha1, sha1);
        memcpy(ref->name, refname, len);
        *local_tail = ref;
        local_tail = &ref->next;
@@ -310,7 +310,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                                continue;
                        }
                }
-               memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
+               hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
                if (is_zero_sha1(ref->new_sha1)) {
                        error("cannot happen anymore");
                        ret = -3;