Revision 7c3fd25dcf2a23ed43bae2ba23a46edab4644a9f authored by Linus Torvalds on 16 January 2008, 00:12:33 UTC, committed by Junio C Hamano on 16 January 2008, 19:37:34 UTC
When creating the commit object, be a whole lot more careful about making
sure that the parent lines really are valid parent lines. Check things
like MERGE_HEAD having proper SHA1 lines in it, and double-check that all
the parents exist and are actually commits.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2862419
Raw File
copy.c
#include "cache.h"

int copy_fd(int ifd, int ofd)
{
	while (1) {
		char buffer[8192];
		char *buf = buffer;
		ssize_t len = xread(ifd, buffer, sizeof(buffer));
		if (!len)
			break;
		if (len < 0) {
			int read_error;
			read_error = errno;
			close(ifd);
			return error("copy-fd: read returned %s",
				     strerror(read_error));
		}
		while (len) {
			int written = xwrite(ofd, buf, len);
			if (written > 0) {
				buf += written;
				len -= written;
			}
			else if (!written) {
				close(ifd);
				return error("copy-fd: write returned 0");
			} else {
				close(ifd);
				return error("copy-fd: write returned %s",
					     strerror(errno));
			}
		}
	}
	close(ifd);
	return 0;
}
back to top