Commit b46ba8c1 authored by tyler wanek's avatar tyler wanek

lock remote during ls execution

parent 3156c14a
......@@ -40,42 +40,52 @@ NAN_METHOD(GitRemote::ReferenceList)
void GitRemote::ReferenceListWorker::Execute()
{
giterr_clear();
baton->error_code = git_remote_connect(
baton->remote,
GIT_DIRECTION_FETCH,
baton->callbacks,
baton->proxy_opts,
baton->custom_headers
);
if (baton->error_code != GIT_OK) {
baton->error = git_error_dup(giterr_last());
delete baton->out;
baton->out = NULL;
return;
}
{
LockMaster lockMaster(
/*asyncAction: */true,
baton->remote,
baton->callbacks,
baton->proxy_opts,
baton->custom_headers
);
baton->error_code = git_remote_connect(
baton->remote,
GIT_DIRECTION_FETCH,
baton->callbacks,
baton->proxy_opts,
baton->custom_headers
);
const git_remote_head **remote_heads;
size_t num_remote_heads;
baton->error_code = git_remote_ls(
&remote_heads,
&num_remote_heads,
baton->remote
);
if (baton->error_code != GIT_OK) {
baton->error = git_error_dup(giterr_last());
delete baton->out;
baton->out = NULL;
return;
}
git_remote_disconnect(baton->remote);
if (baton->error_code != GIT_OK) {
baton->error = git_error_dup(giterr_last());
delete baton->out;
baton->out = NULL;
return;
}
const git_remote_head **remote_heads;
size_t num_remote_heads;
baton->error_code = git_remote_ls(
&remote_heads,
&num_remote_heads,
baton->remote
);
git_remote_disconnect(baton->remote);
if (baton->error_code != GIT_OK) {
baton->error = git_error_dup(giterr_last());
delete baton->out;
baton->out = NULL;
return;
}
baton->out->reserve(num_remote_heads);
baton->out->reserve(num_remote_heads);
for (size_t head_index = 0; head_index < num_remote_heads; ++head_index) {
git_remote_head *remote_head = git_remote_head_dup(remote_heads[head_index]);
baton->out->push_back(remote_head);
for (size_t head_index = 0; head_index < num_remote_heads; ++head_index) {
git_remote_head *remote_head = git_remote_head_dup(remote_heads[head_index]);
baton->out->push_back(remote_head);
}
}
}
......@@ -89,7 +99,6 @@ void GitRemote::ReferenceListWorker::HandleOKCallback()
Nan::Set(result, Nan::New<Number>(i), GitRemoteHead::New(baton->out->at(i), true));
}
delete baton->out;
Local<v8::Value> argv[2] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment