Borrow C strings instead of copying them

Often, we don't need our own copy of a C string as we're simply going to pass it to libgit2 and then free it. In those cases, we can skip the `strdup` and use the underlying C string and use the refcount to make sure we have a valid pointer.

It also fixes a leak in the `IndexEntry` code.