8000 clone: raise source error from credentials cb · libgit2/pygit2@cd09686 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd09686

Browse files
committed
clone: raise source error from credentials cb
Issue #996
1 parent be32579 commit cd09686

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

pygit2/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@ def clone_repository(
223223
branch = checkout_branch or None
224224

225225
# Data, let's use a dict as we don't really want much more
226-
d = {}
227-
d['repository_cb'] = repository
228-
d['remote_cb'] = remote
226+
d = {'repository_cb': repository,
227+
'remote_cb': remote}
229228
d_handle = ffi.new_handle(d)
230229

231230
# Perform the initialization with the version we compiled
@@ -245,7 +244,6 @@ def clone_repository(
245244
opts.remote_cb = _remote_create_cb
246245
opts.remote_cb_payload = d_handle
247246

248-
249247
opts.bare = bare
250248

251249
if callbacks is None:
@@ -255,11 +253,14 @@ def clone_repository(
255253

256254
err = C.git_clone(crepo, to_bytes(url), to_bytes(path), opts)
257255

258-
if 'exception' in d:
259-
raise d['exception']
256+
# Error handling
257+
exc = d.get('exception', callbacks._stored_exception)
258+
if exc:
259+
raise exc
260260

261261
check_error(err)
262262

263+
# Ok
263264
return Repository._from_c(crepo[0], owned=True)
264265

265266

pygit2/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, path=None):
8080
assert_string(path, "path")
8181
err = C.git_config_open_ondisk(cconfig, to_bytes(path))
8282

83-
check_error(err, True)
83+
check_error(err, io=True)
8484
self._config = cconfig[0]
8585

8686
@classmethod
@@ -261,7 +261,7 @@ def parse_int(text):
261261
def _from_found_config(fn):
262262
buf = ffi.new('git_buf *', (ffi.NULL, 0))
263263
err = fn(buf)
264-
check_error(err, True)
264+
check_error(err, io=True)
265265
cpath = ffi.string(buf.ptr).decode('utf-8')
266266
C.git_buf_dispose(buf)
267267

pygit2/index.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ def read(self, force=True):
108108
"""
109109

110110
err = C.git_index_read(self._index, force)
111-
check_error(err, True)
111+
check_error(err, io=True)
112112

113113
def write(self):
114114
"""Write the contents of the Index to disk."""
115115
err = C.git_index_write(self._index)
116-
check_error(err, True)
116+
check_error(err, io=True)
117117

118118
def clear(self):
119119
err = C.git_index_clear(self._index)
@@ -170,14 +170,14 @@ def remove(self, path, level=0):
170170
"""Remove an entry from the Index.
171171
"""
172172
err = C.git_index_remove(self._index, to_bytes(path), level)
173-
check_error(err, True)
173+
check_error(err, io=True)
174174

175175
def remove_all(self, pathspecs):
176176
"""Remove all index entries matching pathspecs.
177177
"""
178178
with StrArray(pathspecs) as arr:
179179
err = C.git_index_remove_all(self._index, arr, ffi.NULL, ffi.NULL)
180-
check_error(err, True)
180+
check_error(err, io=True)
181181

182182
def add_all(self, pathspecs=[]):
183183
"""Add or update index entries matching files in the working directory.
@@ -187,7 +187,7 @@ def add_all(self, pathspecs=[]):
187187
"""
188188
with StrArray(pathspecs) as arr:
189189
err = C.git_index_add_all(self._index, arr, 0, ffi.NULL, ffi.NULL)
190-
check_error(err, True)
190+
check_error(err, io=True)
191191

192192
def add(self, path_or_entry):
193193
"""Add or update an entry in the Index.
@@ -210,7 +210,7 @@ def add(self, path_or_entry):
210210
else:
211211
raise AttributeError('argument must be string or IndexEntry')
212212

213-
check_error(err, True)
213+
check_error(err, io=True)
214214

215215
def diff_to_workdir(self, flags=0, context_lines=3, interhunk_lines=0):
216216
"""

pygit2/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def index(self):
562562
"""Index representing the repository's index file."""
563563
cindex = ffi.new('git_index **')
564564
err = C.git_repository_index(cindex, self._repo)
565-
check_error(err, True)
565+
check_error(err, io=True)
566566

567567
return Index.from_c(self, cindex)
568568

0 commit comments

Comments
 (0)
0