libgit2/libgit2 — pull request #1968 by nulltoken (2013-11-19 12:31:22+00:00)
Title: Corrupted index is bad for your health

While checking out a test repo from .git repository, its index has been unexpectedly LF->CRLF converted.

While git.git was able to gracefully detect the corruption...

```
$ git status
error: bad index file sha1 signature
fatal: index file corrupt
```

...libgit2 was segfaulting.

This PR attempts at fixing this, along with a few issues discovered while working in this area.