Fix for misleading "missing delta bases" error.

This addresses issue libgit2/issues/2721

Created a new pull request. The previous one got mixed with the fix for memory leak issue inadvertently.
Incorporated CR comments from @vmg on previous PR
Thanks. I'll fix it.