From: Thomas Rast <trast@student.ethz.ch>
To: Junio C Hamano <gitster@pobox.com>
Cc: Ralf Thielow <ralf.thielow@gmail.com>, <jk@jk.gs>,
<stimming@tuhh.de>, <git@vger.kernel.org>,
<worldhello.net@gmail.com>
Subject: [PATCH 2/2] merge-recursive: eliminate flush_buffer() in favor of write_in_full()
Date: Fri, 3 Aug 2012 14:16:25 +0200 [thread overview]
Message-ID: <853d452639066df2487b5766160ec2ebb692eab4.1343995614.git.trast@student.ethz.ch> (raw)
In-Reply-To: <6668871a0573c4d82d914137e3c7ff31fa8ce1ef.1343995614.git.trast@student.ethz.ch>
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>
---
Much easier than worrying about the "disk full?" message.
merge-recursive.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index a7bb212..3d4eb82 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -613,23 +613,6 @@ static char *unique_path(struct merge_options *o, const char *path, const char *
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)
{
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);
if (fd < 0)
die_errno(_("failed to open '%s'"), path);
- flush_buffer(fd, buf, size);
+ write_in_full(fd, buf, size);
close(fd);
} else if (S_ISLNK(mode)) {
char *lnk = xmemdupz(buf, size);
--
1.7.12.rc1.219.gb14e69c
next prev parent reply other threads:[~2012-08-03 12:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 17:12 [RFC] l10n: de.po: translate 76 new messages Ralf Thielow
2012-08-03 8:59 ` Thomas Rast
2012-08-03 10:41 ` Ralf Thielow
2012-08-03 12:16 ` Thomas Rast
2012-08-03 12:28 ` Ralf Thielow
2012-08-05 7:13 ` [RFCv2] " Ralf Thielow
2012-08-03 12:16 ` [PATCH 1/2] diff_setup_done(): return void Thomas Rast
2012-08-03 12:16 ` Thomas Rast [this message]
2012-08-03 12:17 ` Thomas Rast
2012-08-03 16:26 ` [RFC] l10n: de.po: translate 76 new messages Ralf Thielow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=853d452639066df2487b5766160ec2ebb692eab4.1343995614.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jk@jk.gs \
--cc=ralf.thielow@gmail.com \
--cc=stimming@tuhh.de \
--cc=worldhello.net@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).