fix hang in git fetch if pointed at a 0 length bundle
git-repo if interupted at the exact wrong time will generate zero length bundles- literal empty files. git-repo is wrong here, but git fetch shouldn't effectively spin loop if pointed at a zero length bundle. Signed-off-by: Brian Harring <ferringb@chromium.org> Helped-by: Johannes Sixt Helped-by: Nguyen Thai Ngoc Duy Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brian Harring committed
Jan 3, 2012 at 05:46 UTC
54440e154f33678a80ea9f77085730b81a5e9446
2 files changed
+8
-2
bundle.c
+2
-2
@@ -31,8 +31,8 @@ static int strbuf_readline_fd(struct strbuf *sb, int fd)
31
while (1) {
32
char ch;
33
ssize_t len = xread(fd, &ch, 1);
34
- if (len < 0)
35
- return -1;
34
+ if (len <= 0)
35
+ return len;
36
strbuf_addch(sb, ch);
37
if (ch == '\n')
38
break;
t/t5704-bundle.sh
+6
@@ -53,4 +53,10 @@ test_expect_failure 'bundle --stdin <rev-list options>' '
53
54
'
55
56
+test_expect_success 'empty bundle file is rejected' '
57
+
58
+ >empty-bundle && test_must_fail git fetch empty-bundle
59
+
60
+'
61
+
62
test_done