Refactor code to get the path to libgit2