X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=apply.c;h=c471a82e83691b152c2b80ea25310afef9b0db95;hb=a325957062b19b49ad75569c59771787c83c350d;hp=1742ab28e95936eed52e910930a8a04869c5418b;hpb=5e80092f7e6db09a40a62e837ca3f74f0bc5ad73;p=git.git diff --git a/apply.c b/apply.c index 1742ab28..c471a82e 100644 --- a/apply.c +++ b/apply.c @@ -84,14 +84,11 @@ static void *read_patch_file(int fd, unsigned long *sizep) buffer = xrealloc(buffer, alloc); nr = alloc - size; } - nr = read(fd, buffer + size, nr); + nr = xread(fd, buffer + size, nr); if (!nr) break; - if (nr < 0) { - if (errno == EAGAIN) - continue; + if (nr < 0) die("git-apply: read returned %s", strerror(errno)); - } size += nr; } *sizep = size; @@ -1006,13 +1003,8 @@ static int read_old_data(struct stat *st, const char *path, void *buf, unsigned return error("unable to open %s", path); got = 0; for (;;) { - int ret = read(fd, buf + got, size - got); - if (ret < 0) { - if (errno == EAGAIN) - continue; - break; - } - if (!ret) + int ret = xread(fd, buf + got, size - got); + if (ret <= 0) break; got += ret; } @@ -1596,16 +1588,13 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf, if (S_ISLNK(mode)) return symlink(buf, path); - fd = open(path, O_CREAT | O_EXCL | O_WRONLY | O_TRUNC, (mode & 0100) ? 0777 : 0666); + fd = open(path, O_CREAT | O_EXCL | O_WRONLY, (mode & 0100) ? 0777 : 0666); if (fd < 0) return -1; while (size) { - int written = write(fd, buf, size); - if (written < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; + int written = xwrite(fd, buf, size); + if (written < 0) die("writing file %s: %s", path, strerror(errno)); - } if (!written) die("out of space writing file %s", path); buf += written; @@ -1646,7 +1635,8 @@ static void create_one_file(const char *path, unsigned mode, const char *buf, un } if (errno != EEXIST) break; - } + ++nr; + } } die("unable to write file %s mode %o", path, mode); }