Commit Diff


commit - 227f81a40643e9c82bb019336421e17e914d015a
commit + 8f74b4995a14ceab9270fcd22a5c1ca34c5cc3be
blob - 1f980e0d7946002349e8aa40fa0eedcdfbd92322
blob + e7220dfb5d8df045791b203031fa93e74e05b407
--- got/got.c
+++ got/got.c
@@ -6408,7 +6408,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;
@@ -6512,10 +6512,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);