commit f89c34e12a475ce35580b05957d2abebeff66b23 from: Stefan Sperling via: Thomas Adam date: Sun Mar 13 21:25:37 2022 UTC make got log, diff, blame, tree, and cat unlock the work tree earlier These commands perform potentially long-running operations on the repository after reading information from the work tree. There is no need for them to keep the work tree locked until the end. Doing so blocks other commands the user may want to run concurrently. For example, the user may want to be able to run 'got diff' in the work tree while browsing 'got log' output in less(1). Pointed out by Misha on gameoftrees IRC. commit - bb2ad8ff07ba26d01c541025d8daaa04723bd280 commit + f89c34e12a475ce35580b05957d2abebeff66b23 blob - 722fa685e1e895ba46accb2c2b0a9ef9f8321fc8 blob + a3510202cfef4ac9f640bafc7d4f8e231cfa0982 --- 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) {