commit 10477b5aacb13088676c3bfd7e0fcc477ba2724e from: Stefan Sperling date: Tue Mar 19 13:22:36 2024 UTC reuse existing repository struct in gotd session update_ref() Avoids pointlessly opening and closing a separate repository instance. commit - 9c177e8d04414b7be4a02d64ed06dcc402a7b0a8 commit + 10477b5aacb13088676c3bfd7e0fcc477ba2724e blob - 402b1ccfef8728b954ba0339814fdc2e1b9c7ba4 blob + b0b449ab2c4db803b92e006427b500772b2d2e55 --- gotd/session.c +++ gotd/session.c @@ -401,7 +401,7 @@ update_ref(int *shut, struct gotd_session_client *clie const char *repo_path, struct imsg *imsg) { const struct got_error *err = NULL; - struct got_repository *repo = NULL; + struct got_repository *repo = gotd_session.repo; struct got_reference *ref = NULL; struct gotd_imsg_ref_update iref; struct got_object_id old_id, new_id; @@ -428,10 +428,6 @@ update_ref(int *shut, struct gotd_session_client *clie return got_error_from_errno("strndup"); log_debug("updating ref %s for uid %d", refname, client->euid); - - err = got_repo_open(&repo, repo_path, NULL, NULL); - if (err) - goto done; memcpy(old_id.sha1, iref.old_id, SHA1_DIGEST_LENGTH); memcpy(new_id.sha1, iref.new_id, SHA1_DIGEST_LENGTH); @@ -555,8 +551,6 @@ done: } if (ref) got_ref_close(ref); - if (repo) - got_repo_close(repo); free(refname); free(id); return err;