commit - 8f74b4995a14ceab9270fcd22a5c1ca34c5cc3be
commit + d0bb0ed648b2dd60e628937450cbaf9200beb9a6
blob - e7220dfb5d8df045791b203031fa93e74e05b407
blob + 488dc79c339ccc7d9f24681ea94bbf19ab7b4309
--- 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);