Skip to content

Commit 4cbfade

Browse files
author
Lukas Fleischer
committed
Fix data type of options in init_repository()
Initializers for the char * fields of the git_repository_init_options structure must be cdata pointers. Signed-off-by: Lukas Fleischer <[email protected]>
1 parent e81d395 commit 4cbfade

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

pygit2/__init__.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,26 @@ def init_repository(path, bare=False,
8686
C.git_repository_init_init_options(options, C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
8787
options.flags = flags
8888
options.mode = mode
89-
options.workdir_path = to_bytes(workdir_path)
90-
options.description = to_bytes(description)
91-
options.template_path = to_bytes(template_path)
92-
options.initial_head = to_bytes(initial_head)
93-
options.origin_url = to_bytes(origin_url)
89+
90+
if workdir_path:
91+
workdir_path_ref = ffi.new('char []', to_bytes(workdir_path))
92+
options.workdir_path = workdir_path_ref
93+
94+
if description:
95+
description_ref = ffi.new('char []', to_bytes(description))
96+
options.description = description_ref
97+
98+
if template_path:
99+
template_path_ref = ffi.new('char []', to_bytes(template_path))
100+
options.template_path = template_path_ref
101+
102+
if initial_head:
103+
initial_head_ref = ffi.new('char []', to_bytes(initial_head))
104+
options.initial_head = initial_head_ref
105+
106+
if origin_url:
107+
origin_url_ref = ffi.new('char []', to_bytes(origin_url))
108+
options.origin_url = origin_url_ref
94109

95110
# Call
96111
crepository = ffi.new('git_repository **')

0 commit comments

Comments
 (0)