X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=init-db.c;h=bd88291b0efd3eb9c46195d413db1aba820db2dd;hb=942c1f53aef03cb3d8b5c39b38997a379c3fad20;hp=2a4aa3c1965f0e2323a1ec3a4f66c0c1206c7d31;hpb=e24317b4d093e4b148996172d0b749f09a0e6f2e;p=git.git diff --git a/init-db.c b/init-db.c index 2a4aa3c1..bd88291b 100644 --- a/init-db.c +++ b/init-db.c @@ -21,7 +21,7 @@ static void safe_create_dir(const char *dir) static int copy_file(const char *dst, const char *src, int mode) { - int fdi, fdo; + int fdi, fdo, status; mode = (mode & 0111) ? 0777 : 0666; if ((fdi = open(src, O_RDONLY)) < 0) @@ -30,30 +30,9 @@ static int copy_file(const char *dst, const char *src, int mode) close(fdi); return fdo; } - while (1) { - char buf[BUFSIZ]; - ssize_t leni, leno, ofs; - leni = read(fdi, buf, sizeof(buf)); - if (leni < 0) { - error_return: - close(fdo); - close(fdi); - return -1; - } - if (!leni) - break; - ofs = 0; - do { - leno = write(fdo, buf+ofs, leni); - if (leno < 0) - goto error_return; - leni -= leno; - ofs += leno; - } while (0 < leni); - } + status = copy_fd(fdi, fdo); close(fdo); - close(fdi); - return 0; + return status; } static void copy_templates_1(char *path, int baselen, @@ -281,10 +260,6 @@ int main(int argc, char **argv) memcpy(path, sha1_dir, len); safe_create_dir(sha1_dir); - for (i = 0; i < 256; i++) { - sprintf(path+len, "/%02x", i); - safe_create_dir(path); - } strcpy(path+len, "/pack"); safe_create_dir(path); strcpy(path+len, "/info");