commit - b2424a42ae549628fe7e8ac9bf5b69af89f59d46
commit + 575ccdcfa027a0819df9f362eaf787142709ce2e
blob - 43915712200e8129be6dcf3d80b1b9a9ba2b6199
blob + 6cca04c7b61becb9df4fb50674ec1414ee0cdbe0
--- got/got.c
+++ got/got.c
static const struct got_error *
cmd_checkout(int argc, char *argv[])
{
- const struct got_error *error = NULL;
+ const struct got_error *close_err, *error = NULL;
struct got_repository *repo = NULL;
struct got_reference *head_ref = NULL, *ref = NULL;
struct got_worktree *worktree = NULL;
if (ref)
got_ref_close(ref);
if (repo) {
- const struct got_error *close_err = got_repo_close(repo);
+ close_err = got_repo_close(repo);
+ if (error == NULL)
+ error = close_err;
+ }
+ if (worktree != NULL) {
+ close_err = got_worktree_close(worktree);
if (error == NULL)
error = close_err;
}
static const struct got_error *
cmd_update(int argc, char *argv[])
{
- const struct got_error *error = NULL;
+ const struct got_error *close_err, *error = NULL;
struct got_repository *repo = NULL;
struct got_worktree *worktree = NULL;
char *worktree_path = NULL;
error = pack_err;
}
if (repo) {
- const struct got_error *close_err = got_repo_close(repo);
+ close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
}
+ if (worktree != NULL) {
+ close_err = got_worktree_close(worktree);
+ if (error == NULL)
+ error = close_err;
+ }
if (head_ref != NULL)
got_ref_close(head_ref);
free(worktree_path);