[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#563882: git-core FTBFS on ia64: t1001-read-tree-m-2way.sh test fails



Andreas Metzler wrote:
> On 2010-01-09 Jonathan Nieder <jrnieder@gmail.com> wrote:

>> -- %< -- M.out
>> 100644 346d4e61f111336a1443ef6b2e834aa5b1a7f91a 0	bozbar
>> 100644 8e4020bb5a8d8c873b25de15933e75cc0fc275df 0	frotz
>> 100644 dca6b92303befc93086aa025d90a5facd7eb2812 0	nitfol
>> -- >% --
>
>> with
>
>> -- %< -- 4.out
>> 100644 346d4e61f111336a1443ef6b2e834aa5b1a7f91a 0	bozbar
>> 100644 8e4020bb5a8d8c873b25de15933e75cc0fc275df 0	frotz
>> 100644 dca6b92303befc93086aa025d90a5facd7eb2812 0	nitfol
>> 100644 0a41e115ab61be0328a19b29f18cdcb49338d516 0	yomin
>> -- >% --
>
>> using 'git diff --no-index M.out 4.out'.

> ametzler@merulo:/tmp/GIT/git-core-1.6.6/t/trash directory.t1001-read-tree-m-2way$ /tmp/GIT/git-core-1.6.6/git diff --no-index M.out 4.out
> diff --git a/M.out b/4.out
> index 4aefa95..d5ec90a 100644
> Binary files a/M.out and b/4.out differ

Hi Andreas and ia64 porters,

If you find time, could you save the is-binary.c in the git source
tree and try

	make git-is-binary
	<M.out ./git-is-binary M.out 4.out

with M.out and 4.out as above?

The idea is to see where binary file detection screws up.  My
current wild guess is that mmap() is misbehaving.

I’ve also attached a diff-debug.patch to ask git diff to reveal
which file it considers binary.

Thanks,
Jonathan
#include "git-compat-util.h"
#include "xdiff-interface.h"

static int xprintf(const char *fmt, ...)
{
	int result = 0;

	va_list ap;
	va_start(ap, fmt);
	if (vprintf(fmt, ap) < 0)
		result = -1;
	va_end(ap);
	return result;
}

static int check_buffer(void)
{
	static const char not_binary[] = 
	"100644 346d4e61f111336a1443ef6b2e834aa5b1a7f91a 0	bozbar\n"
	"100644 8e4020bb5a8d8c873b25de15933e75cc0fc275df 0	frotz\n"
	"100644 dca6b92303befc93086aa025d90a5facd7eb2812 0	nitfol\n";

	return xprintf("static buffer is%s binary\n",
		buffer_is_binary(not_binary, sizeof(not_binary) - 1) ?
		"" : " not");
}

static int check_stdin(void)
{
	static char in_buf[256];
	char *bufp = in_buf;
	char *buf_end = in_buf + sizeof(in_buf);
	ssize_t n;

	while ((n = read(0, bufp, buf_end - bufp))) {
		if (n < 0) {
			perror("stdin: read");
			return -1;
		}
		bufp += n;
	}

	return xprintf("stdin is%s binary\n",
		buffer_is_binary(in_buf, bufp - in_buf) ?
		"" : " not");
}

static ssize_t size(const char *path)
{
	struct stat st;
	if (lstat(path, &st) < 0) {
		fprintf(stderr, "%s: lstat: %s\n",
			path, strerror(errno));
		return -1;
	}
	return st.st_size;
}

static int check_file(const char *path)
{
	ssize_t sz;
	int fd, result;
	void *data;

	if ((sz = size(path)) < 0)
		return -1;
	if ((fd = open(path, O_RDONLY)) < 0) {
		fprintf(stderr, "%s: open: %s\n",
			path, strerror(errno));
		return -1;
	}
	data = mmap(NULL, sz, PROT_READ, MAP_PRIVATE, fd, 0);
	if (data == MAP_FAILED) {
		fprintf(stderr, "%s: mmap: %s\n",
			path, strerror(errno));
		close(fd);
		return -1;
	}
	if (close(fd)) {
		fprintf(stderr, "%s: close: %s\n",
			path, strerror(errno));
		return -1;
	}

	result = xprintf("%s is%s binary\n",
		path,
		buffer_is_binary(data, sz) ?
		"" : " not");

	if (munmap(data, sz)) {
		fprintf(stderr, "%s: munmap: %s\n",
			path, strerror(errno));
		return -1;
	}
	return result;
}

int main(int argc, const char * const argv[])
{
	int result = 0;

	if (argc != 3) {
		fprintf(stderr, "usage: git-is-binary <file> <file>\n");
		exit(1);
	}

	result |= check_buffer();
	result |= check_stdin();
	result |= check_file(argv[1]);
	result |= check_file(argv[2]);
	return result;
}
diff --git a/diff.c b/diff.c
index 08bbd3e..420e4ab 100644
--- a/diff.c
+++ b/diff.c
@@ -1685,6 +1685,10 @@ static void builtin_diff(const char *name_a,
 		else
 			fprintf(o->file, "Binary files %s and %s differ\n",
 				lbl[0], lbl[1]);
+		if (diff_filespec_is_binary(one))
+			fprintf(stderr, "%s is binary\n", lbl[0]);
+		if (diff_filespec_is_binary(two))
+			fprintf(stderr, "%s is binary\n", lbl[1]);
 		o->found_changes = 1;
 	}
 	else {

Reply to: