Staging
v0.5.1
https://github.com/git/git
Revision a153adf683d2b6e22c7e892ed8a161b140156186 authored by Petr Baudis on 24 October 2006, 00:39:14 UTC, committed by Junio C Hamano on 24 October 2006, 02:21:05 UTC
If the commit couldn't have been read, $/ wasn't restored to \n properly,
causing random havoc like git_get_ref_list() returning the ref names with
trailing \n.

Aside of potential confusion in the body of git_search(), no other $/
surprises are hopefully hidden in the code.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 83543a2
Raw File
Tip revision: a153adf683d2b6e22c7e892ed8a161b140156186 authored by Petr Baudis on 24 October 2006, 00:39:14 UTC
gitweb: Fix setting $/ in parse_commit()
Tip revision: a153adf
test-sha1.c
#include "cache.h"

int main(int ac, char **av)
{
	SHA_CTX ctx;
	unsigned char sha1[20];
	unsigned bufsz = 8192;
	char *buffer;

	if (ac == 2)
		bufsz = strtoul(av[1], NULL, 10) * 1024 * 1024;

	if (!bufsz)
		bufsz = 8192;

	while ((buffer = malloc(bufsz)) == NULL) {
		fprintf(stderr, "bufsz %u is too big, halving...\n", bufsz);
		bufsz /= 2;
		if (bufsz < 1024)
			die("OOPS");
	}

	SHA1_Init(&ctx);

	while (1) {
		ssize_t sz, this_sz;
		char *cp = buffer;
		unsigned room = bufsz;
		this_sz = 0;
		while (room) {
			sz = xread(0, cp, room);
			if (sz == 0)
				break;
			if (sz < 0)
				die("test-sha1: %s", strerror(errno));
			this_sz += sz;
			cp += sz;
			room -= sz;
		}
		if (this_sz == 0)
			break;
		SHA1_Update(&ctx, buffer, this_sz);
	}
	SHA1_Final(sha1, &ctx);
	puts(sha1_to_hex(sha1));
	exit(0);
}
back to top