Skip to content

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

Closed

Description

@djmattyg007

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.

Activity

  1. carlosmn commented on Aug 5, 2014

    @carlosmn
    Member

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

  2. djmattyg007 commented on Aug 5, 2014

    @djmattyg007
    ContributorAuthor

    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
    
  3. djmattyg007 commented on Aug 23, 2014

    @djmattyg007
    ContributorAuthor

    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.

  4. carlosmn commented on Aug 25, 2014

    @carlosmn
    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.

  5. added a commit that references this issue on Aug 25, 2014
    b550027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions