Linus Torvalds [off-list ref] wrote:
On Mon, 25 Jun 2007, Jim Meyering wrote:
quoted
Here's a version of that patch that retains the fflush call
and adds a comment explaining why it's needed.
Ok. I will hereby just suggest to Junio that he just not take patches from
you.
You seem to be totally unable to ever really think or worry about your own
little uninteresting test-case, and have shown yourself totally
uninterested in anything anybody ever tells you.
In other words, you now screwed up EPIPE.
AGAIN.
And why? All apparently because you want "disk full" rather than just
"write error".
Jim, you really need to see past your small test, and think about the
bigger picture.
No. I don't keep the "small", git-specific, picture in mind
all the time. Git is the only project I contribute to with
this no-EPIPE restriction, and it doesn't come naturally yet.
Here's the patch you seem to want.
---------------------------------------------------------
Without this patch, git-rev-list unnecessarily omits strerror(errno)
from its diagnostic, upon write failure:
$ ./git-rev-list --max-count=1 HEAD > /dev/full
fatal: write failure on standard output
With the patch, git reports the desired ENOSPC diagnostic:
fatal: write failure on standard output: No space left on device
* builtin-rev-list (show_commit): Diagnose a failed fflush call.
Signed-off-by: Jim Meyering <redacted>
---
builtin-rev-list.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 813aadf..94f8fca 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -100,7 +100,12 @@ static void show_commit(struct commit *commit)
printf("%s%c", buf, hdr_termination);
free(buf);
}
- fflush(stdout);
+
+ /* Flush regularly.
+ This is especially important for an asynchronous consumer. */
+ if (fflush(stdout) && errno != EPIPE)
+ die("write failure on standard output: %s", strerror(errno));
+
if (commit->parents) {
free_commit_list(commit->parents);
commit->parents = NULL;