Skip to content

Commit

Permalink
fix hang in git fetch if pointed at a 0 length bundle
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ferringb authored and gitster committed Jan 3, 2012
1 parent f3f778d commit 54440e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bundle.c
Expand Up @@ -31,8 +31,8 @@ static int strbuf_readline_fd(struct strbuf *sb, int fd)
while (1) {
char ch;
ssize_t len = xread(fd, &ch, 1);
if (len < 0)
return -1;
if (len <= 0)
return len;
strbuf_addch(sb, ch);
if (ch == '\n')
break;
Expand Down
6 changes: 6 additions & 0 deletions t/t5704-bundle.sh
Expand Up @@ -53,4 +53,10 @@ test_expect_failure 'bundle --stdin <rev-list options>' '
'

test_expect_success 'empty bundle file is rejected' '
>empty-bundle && test_must_fail git fetch empty-bundle
'

test_done

0 comments on commit 54440e1

Please sign in to comment.