Download raw body.
Move got_opentempfd out of got_repo_open
On Tue, Jun 07, 2022 at 10:22:10AM -0600, Tracey Emery wrote: > On Mon, Jun 06, 2022 at 04:20:11PM -0600, Tracey Emery wrote: > > On Mon, Jun 06, 2022 at 03:28:16PM -0600, Tracey Emery wrote: > > > Let's give this one a look over. This passes all regress and tog works. > > > This should be tested thoroughly before going in. Comments? Suggestions? > > > > > > -- > > > > > > Tracey Emery > > > > > > > Ok, please disregard this for now. I realized that the tests cannot be > > trusted here. This diff needs every test run on packed repositories to > > be accurate. I need to update tests as well before this can proceed. > > > > -- > > > > Tracey Emery > > > > Ok, here we go. Please look this over. We now pass packed regress > testing (thanks stsp for pointing out GOT_TEST_PACK=1). Comments? Ok? > > -- > > Tracey Emery > This diff applies over the last one. I forgot to come back around and fix gotweb. -- Tracey Emery diff 084c824a63d800c08042507a407b2e666c8d7041 7932a2cbc1ce2efefd480d3d3763be9c28d06286 blob - e36610bb8f42b4e466bde3c7d20d2138169f08df blob + 156fdc229cc2ed2c606d5aded919cc4fa7adeaad --- gotweb/gotweb.c +++ gotweb/gotweb.c @@ -568,7 +568,7 @@ gw_index(struct gw_trans *gw_trans) enum kcgi_err kerr = KCGI_OK; #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", NULL) == -1) { error = got_error_from_errno("pledge"); return error; @@ -972,7 +972,7 @@ gw_commits(struct gw_trans *gw_trans) return got_error_from_errno("malloc"); #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", NULL) == -1) { error = got_error_from_errno("pledge"); goto done; @@ -1199,7 +1199,7 @@ gw_briefs(struct gw_trans *gw_trans) return got_error_from_errno("malloc"); #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", NULL) == -1) { error = got_error_from_errno("pledge"); goto done; @@ -1459,7 +1459,8 @@ gw_summary(struct gw_trans *gw_trans) enum kcgi_err kerr = KCGI_OK; #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1) + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", + NULL) == -1) return got_error_from_errno("pledge"); #endif error = gw_apply_unveil(gw_trans->gw_dir->path); @@ -1622,7 +1623,8 @@ gw_tree(struct gw_trans *gw_trans) enum kcgi_err kerr = KCGI_OK; #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1) + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", + NULL) == -1) return got_error_from_errno("pledge"); #endif if ((header = gw_init_header()) == NULL) @@ -1697,7 +1699,8 @@ gw_tags(struct gw_trans *gw_trans) enum kcgi_err kerr = KCGI_OK; #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1) + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", + NULL) == -1) return got_error_from_errno("pledge"); #endif if ((header = gw_init_header()) == NULL) @@ -1813,7 +1816,7 @@ gw_tag(struct gw_trans *gw_trans) enum kcgi_err kerr = KCGI_OK; #ifndef PROFILE - if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1) + if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", NULL) == -1) return got_error_from_errno("pledge"); #endif if ((header = gw_init_header()) == NULL) @@ -2801,9 +2804,6 @@ gw_get_repo_age(char **repo_age, struct gw_trans *gw_t error = got_repo_open(&repo, dir, NULL, pack_fds); if (error) return error; - error = got_repo_pack_fds_close(pack_fds); - if (error) - return error; } error = got_ref_list(&refs, repo, "refs/heads", @@ -2851,6 +2851,12 @@ done: if (error == NULL) error = close_err; } + if (pack_fds) { + const struct got_error *pack_err = + got_repo_pack_fds_close(pack_fds); + if (error == NULL) + error = pack_err; + } return error; } @@ -2975,9 +2981,6 @@ gw_get_repo_owner(char **owner, struct gw_trans *gw_tr error = got_repo_open(&repo, dir, NULL, pack_fds); if (error) return error; - error = got_repo_pack_fds_close(pack_fds); - if (error) - return error; gitconfig_owner = got_repo_get_gitconfig_owner(repo); if (gitconfig_owner) { @@ -2988,6 +2991,12 @@ gw_get_repo_owner(char **owner, struct gw_trans *gw_tr close_err = got_repo_close(repo); if (error == NULL) error = close_err; + if (pack_fds) { + const struct got_error *pack_err = + got_repo_pack_fds_close(pack_fds); + if (error == NULL) + error = pack_err; + } return error; } @@ -3796,9 +3805,6 @@ gw_get_header(struct gw_trans *gw_trans, struct gw_hea pack_fds); if (error) return error; - error = got_repo_pack_fds_close(pack_fds); - if (error) - return error; if (gw_trans->commit_id == NULL || gw_trans->action == GW_COMMITS || gw_trans->action == GW_BRIEFS || gw_trans->action == GW_SUMMARY || @@ -3878,7 +3884,12 @@ gw_get_header(struct gw_trans *gw_trans, struct gw_hea error = gw_get_commits(gw_trans, header, limit, id); done: - got_ref_list_free(&header->refs); + if (pack_fds) { + const struct got_error *pack_err = + got_repo_pack_fds_close(pack_fds); + if (error == NULL) + error = pack_err; + } free(id); free(in_repo_path); return error; @@ -4870,17 +4881,17 @@ main(int argc, char *argv[]) if (error) goto done; - if (gw_trans->action == GW_BLOB) - error = gw_blob(gw_trans); - else - error = gw_display_index(gw_trans); -done: if (gw_trans->repo) { const struct got_error *close_err; close_err = got_repo_close(gw_trans->repo); if (error == NULL) error = close_err; } + if (gw_trans->action == GW_BLOB) + error = gw_blob(gw_trans); + else + error = gw_display_index(gw_trans); +done: if (error) { gw_trans->error = error; gw_trans->action = GW_ERR;
Move got_opentempfd out of got_repo_open