Commit Diff


commit - 6e96b3268181f675fcf264d5e682d86a15ce426a
commit + f7fce2e256045540640f55a619a55eea6ec859fa
blob - 17d637cabb59cb76c220d33c371c8c2a25da94cf
blob + 09c52c1e9bd95ceb4f5fa1f135b3fb570b7285b0
--- got/got.c
+++ got/got.c
@@ -4266,6 +4266,12 @@ cmd_log(int argc, char *argv[])
 		path = in_repo_path;
 	}
 
+	if (worktree) {
+		/* Release work tree lock. */
+		got_worktree_close(worktree);
+		worktree = NULL;
+	}
+
 	error = print_commits(start_id, end_id, repo, path ? path : "",
 	    show_changed_paths, show_patch, search_pattern, diff_context,
 	    limit, log_branches, reverse_display_order, refs_idmap);
@@ -4796,6 +4802,12 @@ cmd_diff(int argc, char *argv[])
 			free(in_repo_path);
 		if (error)
 			goto done;
+	}
+
+	if (worktree) {
+		/* Release work tree lock. */
+		got_worktree_close(worktree);
+		worktree = NULL;
 	}
 
 	switch (type1 == GOT_OBJ_TYPE_ANY ? type2 : type1) {
@@ -5091,6 +5103,12 @@ cmd_blame(int argc, char *argv[])
 		got_ref_list_free(&refs);
 		if (error)
 			goto done;
+	}
+
+	if (worktree) {
+		/* Release work tree lock. */
+		got_worktree_close(worktree);
+		worktree = NULL;
 	}
 
 	error = got_object_resolve_symlinks(&link_target, in_repo_path,
@@ -5435,6 +5453,12 @@ cmd_tree(int argc, char *argv[])
 			goto done;
 	}
 
+	if (worktree) {
+		/* Release work tree lock. */
+		got_worktree_close(worktree);
+		worktree = NULL;
+	}
+
 	error = print_tree(in_repo_path, commit_id, show_ids, recurse,
 	    in_repo_path, repo);
 done:
@@ -11767,6 +11791,10 @@ cmd_cat(int argc, char *argv[])
 				goto done;
 			}
 		}
+
+		/* Release work tree lock. */
+		got_worktree_close(worktree);
+		worktree = NULL;
 	}
 
 	if (repo_path == NULL) {