Staging
v0.5.1
https://github.com/git/git
Revision d5e86da89155b462c30a59bc724037fb111d3894 authored by Junio C Hamano on 26 December 2006, 02:14:12 UTC, committed by Junio C Hamano on 26 December 2006, 02:39:54 UTC
This is not yet -rc1 where all new topics closes, but I think it
is getting pretty closer.  I'd still want to merge updates to
fsck/prune to honor reflog entries before -rc1.

Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d2bafe5
Raw File
Tip revision: d5e86da89155b462c30a59bc724037fb111d3894 authored by Junio C Hamano on 26 December 2006, 02:14:12 UTC
GIT v1.5.0 preview
Tip revision: d5e86da
write_or_die.c
#include "cache.h"

void write_or_die(int fd, const void *buf, size_t count)
{
	const char *p = buf;
	ssize_t written;

	while (count > 0) {
		written = xwrite(fd, p, count);
		if (written == 0)
			die("disk full?");
		else if (written < 0) {
			if (errno == EPIPE)
				exit(0);
			die("write error (%s)", strerror(errno));
		}
		count -= written;
		p += written;
	}
}

int write_or_whine(int fd, const void *buf, size_t count, const char *msg)
{
	const char *p = buf;
	ssize_t written;

	while (count > 0) {
		written = xwrite(fd, p, count);
		if (written == 0) {
			fprintf(stderr, "%s: disk full?\n", msg);
			return 0;
		}
		else if (written < 0) {
			if (errno == EPIPE)
				exit(0);
			fprintf(stderr, "%s: write error (%s)\n",
				msg, strerror(errno));
			return 0;
		}
		count -= written;
		p += written;
	}

	return 1;
}
back to top