'git fast-export' is crashing on the gcc repo

Subsystems: the rest

7 messages, 3 authors, 2016-06-15 · open the first message on its own page

'git fast-export' is crashing on the gcc repo

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:58

Simply doing something like:

$ git fast-export --all > /dev/null

results in:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391

Since this is extremely enlightening, I patched it as follows:
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..5c7bfe0 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -104,7 +104,8 @@ static void handle_object(const unsigned char *sha1)
 
 	printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
 	if (fwrite(buf, size, 1, stdout) != 1)
-		die ("Could not write blob %s", sha1_to_hex(sha1));
+		die ("Could not write blob %s: %s",
+		     sha1_to_hex(sha1), strerror(errno));
 	printf("\n");
 
 	show_progress();
And then running it again produced:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391: Inappropriate ioctl for device

adding to today's confusion.


Nicolas

Re: 'git fast-export' is crashing on the gcc repo

From: Marco Costalba <hidden>
Date: 2016-06-15 22:43:58

On Dec 11, 2007 9:27 PM, Nicolas Pitre [off-list ref] wrote:
And then running it again produced:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391: Inappropriate ioctl for device

adding to today's confusion.
GCC repo is turning out to be a very good test case indeed ;-)

[PATCH] Fix git-fast-export for zero-sized blobs

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:58

Signed-off-by: Alex Riesen <redacted>
---
 builtin-fast-export.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Nicolas Pitre, Tue, Dec 11, 2007 21:27:33 +0100:
Simply doing something like:

$ git fast-export --all > /dev/null

results in:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
I get this for my git repo:

	$ git fast-export --all >/dev/null
	fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
	$ git cat-file blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |wc -c
	0

Writing a zero-size blob will surely returns 0.
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..ef27eee 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
 	mark_object(object);
 
 	printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
-	if (fwrite(buf, size, 1, stdout) != 1)
+	if (size && fwrite(buf, size, 1, stdout) != 1)
 		die ("Could not write blob %s", sha1_to_hex(sha1));
 	printf("\n");
 
-- 
1.5.3.7.1177.gb22b

Re: 'git fast-export' is crashing on the gcc repo

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:58

On Tue, 11 Dec 2007, Nicolas Pitre wrote:
quoted hunk
Simply doing something like:

$ git fast-export --all > /dev/null

results in:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391

Since this is extremely enlightening, I patched it as follows:
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..5c7bfe0 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -104,7 +104,8 @@ static void handle_object(const unsigned char *sha1)
 
 	printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
 	if (fwrite(buf, size, 1, stdout) != 1)
-		die ("Could not write blob %s", sha1_to_hex(sha1));
+		die ("Could not write blob %s: %s",
+		     sha1_to_hex(sha1), strerror(errno));
 	printf("\n");
 
 	show_progress();
And then running it again produced:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391: Inappropriate ioctl for device

adding to today's confusion.
Well, ignore the above.  It seems that most of stdio doesn't set errno 
so the above is crap.

Even strace doesn't show any error.

But, somehow, the following patch fixes it:
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..c32a124 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
 	mark_object(object);
 
 	printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
-	if (fwrite(buf, size, 1, stdout) != 1)
+	if (fwrite(buf, 1, size, stdout) != size)
 		die ("Could not write blob %s", sha1_to_hex(sha1));
 	printf("\n");
 
Go figure.


Nicolas

Re: [PATCH] Fix git-fast-export for zero-sized blobs

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:58

On Tue, 11 Dec 2007, Alex Riesen wrote:
Signed-off-by: Alex Riesen <redacted>
---
 builtin-fast-export.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Nicolas Pitre, Tue, Dec 11, 2007 21:27:33 +0100:
quoted
Simply doing something like:

$ git fast-export --all > /dev/null

results in:

fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
I get this for my git repo:

	$ git fast-export --all >/dev/null
	fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
	$ git cat-file blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |wc -c
	0

Writing a zero-size blob will surely returns 0.
Indeed.


/me looking at too many piece of code at the same time


Nicolas

Re: 'git fast-export' is crashing on the gcc repo

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:58

Nicolas Pitre, Tue, Dec 11, 2007 23:06:42 +0100:
Well, ignore the above.  It seems that most of stdio doesn't set errno 
so the above is crap.
Well, it had no reason to in this case. It's not an error.
It does not even have to do a syscall.
quoted hunk
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..c32a124 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
 	mark_object(object);
 
 	printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
-	if (fwrite(buf, size, 1, stdout) != 1)
+	if (fwrite(buf, 1, size, stdout) != size)
That's a probable syscall which could be spared

Re: 'git fast-export' is crashing on the gcc repo

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:58

On Wed, 12 Dec 2007, Alex Riesen wrote:
Nicolas Pitre, Tue, Dec 11, 2007 23:06:42 +0100:
quoted
Well, ignore the above.  It seems that most of stdio doesn't set errno 
so the above is crap.
Well, it had no reason to in this case. It's not an error.
It does not even have to do a syscall.
Which is why I later agreed with your patch.


Nicolas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help