Re: [PATCH] git-rev-list: give better diagnostic for failed write
- From
Jim Meyering <jim@meyering.net>
- Date
- Jun 25, 2007, 21:39 UTC
- Message-ID
- <87bqf3u324.fsf@rho.meyering.net>
- In-Reply-To
- <87r6nzu666.fsf@rho.meyering.net>
Jim Meyering <jim@meyering.net> wrote:
> [this patch depends on the one I posted here: > http://marc.info/?l=git&m=118280134031923&w=2 ]
Here's a version of that patch that retains the fflush call and adds a comment explaining why it's needed.
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 outputWith 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 <jim@meyering.net> --- 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..f13a594 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)) + die("write failure on standard output: %s", strerror(errno)); + if (commit->parents) { free_commit_list(commit->parents); commit->parents = NULL;