Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing checkout_branch to pygit2.clone_repository() triggers a fatal error #399

Closed
djmattyg007 opened this issue Aug 5, 2014 · 4 comments · Fixed by #411
Closed

Passing checkout_branch to pygit2.clone_repository() triggers a fatal error #399

djmattyg007 opened this issue Aug 5, 2014 · 4 comments · Fixed by #411

Comments

@djmattyg007
Copy link
Contributor

Whenever I try and clone any repository with something like the following command:

repo = pygit2.clone_repository(url="file:///srv/samba/files/programming/cli/modman-test", path="/tmp/modman")

The entire contents of the repo are staged for deletion.

I tried to get around this by passing 'checkout_branch="master"' to the clone_repository() function (as this fixes the issue just fine when I run 'git checkout master' from my shell), but that triggers a fatal error.

@carlosmn
Copy link
Member

carlosmn commented Aug 5, 2014

Which error? Which is the active branch in the source repository?

@djmattyg007
Copy link
Contributor Author

The active branch is master. This is line of code I'm trying to run:

repo = pygit2.clone_repository(url="file:///srv/samba/files/programming/cli/modman-test", path="/tmp/modman", checkout_branch="master")

And this is the full error I get:

Traceback (most recent call last):
File "modman.py", line 8, in <module>
repo = git.clone_repository(url="file:///srv/samba/files/programming/cli/modman-test", path="/tmp/modman", checkout_branch="master")
File "/usr/lib/python3.4/site-packages/pygit2/__init__.py", line 156, in clone_repository
checkout_branch_ref = ffi.new('char []', branch)
File "/usr/lib/python3.4/site-packages/cffi/api.py", line 225, in new
return self._backend.newp(cdecl, init)
TypeError: initializer for ctype 'char[]' must be a bytes or list or tuple, not str

@djmattyg007
Copy link
Contributor Author

I've just discovered that the "test_clone_checkout_branch" test in the repository test suite is commented out because it's broken, which probably explains why this use case isn't working for me.

I feel like the documentation should be updated to reflect this until it is fixed, as it can be quite frustrating for someone who doesn't know.

@carlosmn
Copy link
Member

The test is commented out for a different reason, explained in the comment block. As you can see from the error message, the issue here is down to a type mismatch, which looks like a missing to_bytes() when setting up the struct.

carlosmn added a commit to carlosmn/pygit2 that referenced this issue Aug 25, 2014
We were missing a cast to bytes. Add a test for this option as well and
remove the old commented-out test for checkout_branch, which is
superseded by this one and whose last bit seemed confused about what the
option means.

This fixes libgit2#399
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants