commit - 991ff1aa4f423a1faea1bae0e85a913a88038309
commit + 1d0f405485b02cc4480ea188879e4122e0ea32bd
blob - 192b847bcb16c4c5fe215175d5a8109d0712f76b
blob + 097226da2568c25ff532d61bf72b41de086e3af9
--- got/got.c
+++ got/got.c
}
if (fetchfd != -1 && close(fetchfd) == -1 && error == NULL)
error = got_error_from_errno("close");
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
TAILQ_FOREACH(pe, &refs, entry) {
free((void *)pe->path);
free(pe->data);
}
if (fetchfd != -1 && close(fetchfd) == -1 && error == NULL)
error = got_error_from_errno("close");
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
TAILQ_FOREACH(pe, &refs, entry) {
if (worktree)
got_worktree_close(worktree);
if (repo) {
- const struct got_error *repo_error;
- repo_error = got_repo_close(repo);
+ const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
- error = repo_error;
+ error = close_err;
}
if (refs_idmap)
got_reflist_object_id_map_free(refs_idmap);
if (worktree)
got_worktree_close(worktree);
if (repo) {
- const struct got_error *repo_error;
- repo_error = got_repo_close(repo);
+ const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
- error = repo_error;
+ error = close_err;
}
got_ref_list_free(&refs);
return error;
if (worktree)
got_worktree_close(worktree);
if (repo) {
- const struct got_error *repo_error;
- repo_error = got_repo_close(repo);
+ const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
- error = repo_error;
+ error = close_err;
}
if (bca.lines) {
for (i = 0; i < bca.nlines; i++) {
if (worktree)
got_worktree_close(worktree);
if (repo) {
- const struct got_error *repo_error;
- repo_error = got_repo_close(repo);
+ const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
- error = repo_error;
+ error = close_err;
}
return error;
}
}
done:
free(refname);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(cwd);
done:
if (ref)
got_ref_close(ref);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(cwd);
commit_id_str ? commit_id_str : commit_id_arg, tagmsg);
}
done:
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(cwd);
error = got_worktree_schedule_add(worktree, &paths, add_progress,
NULL, repo, no_ignores);
done:
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
TAILQ_FOREACH(pe, &paths, entry)
delete_local_mods, status_codes, print_remove_status, NULL,
repo, keep_on_disk);
done:
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
TAILQ_FOREACH(pe, &paths, entry)
if (patch_script_file && fclose(patch_script_file) == EOF &&
error == NULL)
error = got_error_from_errno2("fclose", patch_script_path);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(path);
error == NULL)
error = got_error_from_errno2("unlink", cl_arg.logmsg_path);
free(cl_arg.logmsg_path);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(cwd);
got_ref_close(head_ref);
if (worktree)
got_worktree_close(worktree);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
return error;
}
got_ref_close(head_ref);
if (worktree)
got_worktree_close(worktree);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
return error;
}
got_ref_close(tmp_branch);
if (worktree)
got_worktree_close(worktree);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
return error;
}
got_ref_close(tmp_branch);
if (worktree)
got_worktree_close(worktree);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
return error;
}
printf("Integrated %s into %s\n", refname, base_refname);
print_update_progress_stats(&upa);
done:
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(cwd);
if (patch_script_file && fclose(patch_script_file) == EOF &&
error == NULL)
error = got_error_from_errno2("fclose", patch_script_path);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
TAILQ_FOREACH(pe, &paths, entry)
if (patch_script_file && fclose(patch_script_file) == EOF &&
error == NULL)
error = got_error_from_errno2("fclose", patch_script_path);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
TAILQ_FOREACH(pe, &paths, entry)
if (worktree)
got_worktree_close(worktree);
if (repo) {
- const struct got_error *repo_error;
- repo_error = got_repo_close(repo);
+ const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
- error = repo_error;
+ error = close_err;
}
got_ref_list_free(&refs);
return error;
blob - 4cc5428af954c47772c98d07aff210d72929cc7c
blob + 3a689cd14ad0dacbec839cd0d7dead37f4d5f83c
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
}
done:
got_ref_list_free(&refs);
- if (gw_trans->repo == NULL)
- got_repo_close(repo);
+ if (gw_trans->repo == NULL) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
return error;
}
static const struct got_error *
gw_get_repo_owner(char **owner, struct gw_trans *gw_trans, char *dir)
{
- const struct got_error *error = NULL;
+ const struct got_error *error = NULL, *close_err;
struct got_repository *repo;
const char *gitconfig_owner;
if (*owner == NULL)
error = got_error_from_errno("strdup");
}
- got_repo_close(repo);
+ close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
return error;
}
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 (error) {
gw_trans->error = error;
gw_trans->action = GW_ERR;
free(gw_trans->prev_id);
free(gw_trans->prev_prev_id);
free(gw_trans->repo_path);
- if (gw_trans->repo)
- got_repo_close(gw_trans->repo);
-
TAILQ_FOREACH_SAFE(dir, &gw_trans->gw_dirs, entry, tdir) {
free(dir->name);
free(dir->description);
blob - 16616cca614bcd144f1e84477ab65ea3f34b7b0e
blob + 2f1abf58087e2648591e03485c907e2b79bb7baa
--- lib/repository.c
+++ lib/repository.c
err = got_error_from_errno("close");
}
- if (repo->gitdir_fd != -1)
- close(repo->gitdir_fd);
+ if (repo->gitdir_fd != -1 && close(repo->gitdir_fd) == -1 &&
+ err == NULL)
+ err = got_error_from_errno("close");
if (repo->gotconfig)
got_gotconfig_free(repo->gotconfig);
blob - 13cc9fbaca9c08dbb86084c978e908bee7eebe17
blob + 522c2fe12ca9c96345952c0586dcca8194d69202
--- lib/worktree.c
+++ lib/worktree.c
goto done;
}
done:
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (err == NULL)
+ err = close_err;
+ }
free(path_got);
free(path_lock);
free(base_commit_id_str);
blob - c426e9d11b25926d3d473cea50910a6e8ecd3240
blob + b6840e939dec6d2d98e812c0a0ca34d74e03eee1
--- tog/tog.c
+++ tog/tog.c
}
if (s->thread_args.repo) {
- got_repo_close(s->thread_args.repo);
+ err = got_repo_close(s->thread_args.repo);
s->thread_args.repo = NULL;
}
free(label);
if (ref)
got_ref_close(ref);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
tog_free_refs();
free(label2);
free(repo_path);
free(cwd);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
tog_free_refs();
static void *
blame_thread(void *arg)
{
- const struct got_error *err;
+ const struct got_error *err, *close_err;
struct tog_blame_thread_args *ta = arg;
struct tog_blame_cb_args *a = ta->cb_args;
int errcode;
return (void *)got_error_set_errno(errcode,
"pthread_mutex_lock");
- got_repo_close(ta->repo);
+ close_err = got_repo_close(ta->repo);
+ if (err == NULL)
+ err = close_err;
ta->repo = NULL;
*ta->complete = 1;
blame->thread = NULL;
}
if (blame->thread_args.repo) {
- got_repo_close(blame->thread_args.repo);
+ const struct got_error *close_err;
+ close_err = got_repo_close(blame->thread_args.repo);
+ if (err == NULL)
+ err = close_err;
blame->thread_args.repo = NULL;
}
if (blame->f) {
free(commit_id);
if (worktree)
got_worktree_close(worktree);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
tog_free_refs();
return error;
}
got_object_commit_close(commit);
if (tree)
got_object_tree_close(tree);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
tog_free_refs();
return error;
}
done:
free(repo_path);
free(cwd);
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ const struct got_error *close_err = got_repo_close(repo);
+ if (close_err)
+ error = close_err;
+ }
tog_free_refs();
return error;
}
static const struct got_error *
tog_log_with_path(int argc, char *argv[])
{
- const struct got_error *error = NULL;
+ const struct got_error *error = NULL, *close_err;
struct tog_cmd *cmd = NULL;
struct got_repository *repo = NULL;
struct got_worktree *worktree = NULL;
/* not reached */
}
- got_repo_close(repo);
+ close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
repo = NULL;
error = got_object_id_str(&commit_id_str, commit_id);
cmd_argv = make_argv(argc, cmd->name, "-c", commit_id_str, argv[0]);
error = cmd->cmd_main(argc, cmd_argv);
done:
- if (repo)
- got_repo_close(repo);
+ if (repo) {
+ close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
if (worktree)
got_worktree_close(worktree);
free(id);