Skip to content

Commit f633ea2

Browse files
trastgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0f1ea6 commit f633ea2

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

merge-recursive.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -613,23 +613,6 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
613613
return newpath;
614614
}
615615

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-
633616
static int dir_in_way(const char *path, int check_working_copy)
634617
{
635618
int pos, pathlen = strlen(path);
@@ -788,7 +771,7 @@ static void update_file_flags(struct merge_options *o,
788771
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
789772
if (fd < 0)
790773
die_errno("failed to open '%s'", path);
791-
flush_buffer(fd, buf, size);
774+
write_in_full(fd, buf, size);
792775
close(fd);
793776
} else if (S_ISLNK(mode)) {
794777
char *lnk = xmemdupz(buf, size);

0 commit comments

Comments
 (0)