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>
This commit is contained in:

committed by
Junio C Hamano

parent
d0f1ea6003
commit
f633ea2c73
@ -613,23 +613,6 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
|
|||||||
return newpath;
|
return newpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_buffer(int fd, const char *buf, unsigned long size)
|
|
||||||
{
|
|
||||||
while (size > 0) {
|
|
||||||
long ret = write_in_full(fd, buf, size);
|
|
||||||
if (ret < 0) {
|
|
||||||
/* Ignore epipe */
|
|
||||||
if (errno == EPIPE)
|
|
||||||
break;
|
|
||||||
die_errno("merge-recursive");
|
|
||||||
} else if (!ret) {
|
|
||||||
die("merge-recursive: disk full?");
|
|
||||||
}
|
|
||||||
size -= ret;
|
|
||||||
buf += ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dir_in_way(const char *path, int check_working_copy)
|
static int dir_in_way(const char *path, int check_working_copy)
|
||||||
{
|
{
|
||||||
int pos, pathlen = strlen(path);
|
int pos, pathlen = strlen(path);
|
||||||
@ -788,7 +771,7 @@ static void update_file_flags(struct merge_options *o,
|
|||||||
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
|
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
die_errno("failed to open '%s'", path);
|
die_errno("failed to open '%s'", path);
|
||||||
flush_buffer(fd, buf, size);
|
write_in_full(fd, buf, size);
|
||||||
close(fd);
|
close(fd);
|
||||||
} else if (S_ISLNK(mode)) {
|
} else if (S_ISLNK(mode)) {
|
||||||
char *lnk = xmemdupz(buf, size);
|
char *lnk = xmemdupz(buf, size);
|
||||||
|
Reference in New Issue
Block a user