Commit Diff


commit - 0af390fca55d091e85fdf6b89772471083a8bad5
commit + b2424a42ae549628fe7e8ac9bf5b69af89f59d46
blob - 802320b0b95a53b2c163b2e107f19f76d99309cd
blob + 43915712200e8129be6dcf3d80b1b9a9ba2b6199
--- got/got.c
+++ got/got.c
@@ -6407,7 +6407,7 @@ print:
 static const struct got_error *
 cmd_status(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;
 	struct got_status_arg st;
@@ -6511,10 +6511,15 @@ done:
 			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;
+	}
 
 	got_pathlist_free(&paths, GOT_PATHLIST_FREE_PATH);
 	free(cwd);