git: add support for cloning empty repos #393
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for cloning empty repos using
go-git
andlibgit2
.go-git
returns an error when cloning an empty repository directly, which is handled by using the advice provided here: go-git/go-git#118 (comment).libgit2
doesn't return an error and thus the change is much simpler.The
go-git
package gets test coverage for this scenario but thelibgit2
package does not because of the following weird behavior:To make sure the changes to the
libgit2
package have the intended effect, it was tested (and confirmed to have the correct behavior) using empty repos on GitHub and GitLab.(same goes for thego-git
package as well).Signed-off-by: Sanskar Jaiswal jaiswalsanskar078@gmail.com