merge-recursive: eliminate flush_buffer() in favor of write_in_full()

flush_buffer() is a thin wrapper around write_in_full() with two very confusing properties: * It runs a loop to handle short reads, ensuring that we write everything. But that is precisely what write_in_full() does! * It checks for a return value of 0 from write_in_full(), which cannot happen: it returns this value only if count=0, but flush_buffer() will never call write_in_full() in this case. Remove it. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Aug 3, 2012 at 14:16 UTC f633ea2c736a2a38e92fcf61e90c8adadc5c504d
1 file changed +1 -18
merge-recursive.c
+1 -18
@@ -613,23 +613,6 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
613 return newpath;
614 }
615
616 -static void flush_buffer(int fd, const char *buf, unsigned long size)
617 -{
618 - while (size > 0) {
619 - long ret = write_in_full(fd, buf, size);
620 - if (ret < 0) {
621 - /* Ignore epipe */
622 - if (errno == EPIPE)
623 - break;
624 - die_errno("merge-recursive");
625 - } else if (!ret) {
626 - die("merge-recursive: disk full?");
627 - }
628 - size -= ret;
629 - buf += ret;
630 - }
631 -}
632 -
616 static int dir_in_way(const char *path, int check_working_copy)
617 {
618 int pos, pathlen = strlen(path);
@@ -788,7 +771,7 @@ static void update_file_flags(struct merge_options *o,
771 fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
772 if (fd < 0)
773 die_errno("failed to open '%s'", path);
791 - flush_buffer(fd, buf, size);
774 + write_in_full(fd, buf, size);
775 close(fd);
776 } else if (S_ISLNK(mode)) {
777 char *lnk = xmemdupz(buf, size);