Skip to content

Commit

Permalink
don't duplicate repo when getting remotes
Browse files Browse the repository at this point in the history
I didn't realize this beforehand but the git_remote object takes the pointer to the repo it's looked up on. Then when we construct a GitRemote, we create a wrapper around *that* repo pointer(because we create a new repository instance per-remote...) which gets garbage collected later. I still don't see a good reason to duplicate the repo pointer and we don't in other cases of constructing GitRemote so I'm gonna remove it.
  • Loading branch information
zawata committed Apr 19, 2024
1 parent a711416 commit b854f75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 2 additions & 0 deletions generate/templates/manual/repository/get_references.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void GitRepository::GetReferencesWorker::Execute()
baton->out->push_back(reference);
}
}

git_strarray_free(&reference_names);
}

void GitRepository::GetReferencesWorker::HandleErrorCallback() {
Expand Down
8 changes: 1 addition & 7 deletions generate/templates/manual/repository/get_remotes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ void GitRepository::GetRemotesWorker::Execute()
{
giterr_clear();

git_repository *repo;
{
nodegit::LockMaster lockMaster(true, baton->repo);
baton->error_code = git_repository_open(&repo, git_repository_workdir(baton->repo));
}
git_repository *repo = baton->repo;

if (baton->error_code != GIT_OK) {
if (giterr_last() != NULL) {
Expand All @@ -52,7 +48,6 @@ void GitRepository::GetRemotesWorker::Execute()
baton->error = git_error_dup(giterr_last());
}

git_repository_free(repo);
delete baton->out;
baton->out = NULL;
return;
Expand Down Expand Up @@ -86,7 +81,6 @@ void GitRepository::GetRemotesWorker::Execute()
}

git_strarray_free(&remote_names);
git_repository_free(repo);
}

void GitRepository::GetRemotesWorker::HandleErrorCallback() {
Expand Down

0 comments on commit b854f75

Please sign in to comment.