commit a086872af94cfb4c16769d9255ca2211552c5317 from: Stefan Sperling via: Thomas Adam date: Sat Apr 16 08:06:59 2022 UTC make 'got tag' unlock the work tree earlier when creating tags The work tree was only held open in order to find its got.conf file since this file could contain a tagger name to use. Read the tagger name earlier. Once the tagger name is known we can close the work tree already. commit - f23456fbfb95d8089a0126438d76525b5955a136 commit + a086872af94cfb4c16769d9255ca2211552c5317 blob - f5978be88b972b41efa6edf3e0bf75ae89144418 blob + 68e48a0e81d4d3c15d2ddcf8300302b93d22fab4 --- got/got.c +++ got/got.c @@ -6591,14 +6591,14 @@ done: } static const struct got_error * -add_tag(struct got_repository *repo, struct got_worktree *worktree, +add_tag(struct got_repository *repo, const char *tagger, const char *tag_name, const char *commit_arg, const char *tagmsg_arg) { const struct got_error *err = NULL; struct got_object_id *commit_id = NULL, *tag_id = NULL; char *label = NULL, *commit_id_str = NULL; struct got_reference *ref = NULL; - char *refname = NULL, *tagmsg = NULL, *tagger = NULL; + char *refname = NULL, *tagmsg = NULL; char *tagmsg_path = NULL, *tag_id_str = NULL; int preserve_tagmsg = 0; struct got_reflist_head refs; @@ -6613,10 +6613,6 @@ add_tag(struct got_repository *repo, struct got_worktr if (tag_name[0] == '-') return got_error_path(tag_name, GOT_ERR_REF_NAME_MINUS); - err = get_author(&tagger, repo, worktree); - if (err) - return err; - err = got_ref_list(&refs, repo, NULL, got_ref_cmp_by_name, NULL); if (err) goto done; @@ -6703,7 +6699,6 @@ done: free(refname); free(tagmsg); free(tagmsg_path); - free(tagger); got_ref_list_free(&refs); return err; } @@ -6715,7 +6710,7 @@ cmd_tag(int argc, char *argv[]) struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; char *cwd = NULL, *repo_path = NULL, *commit_id_str = NULL; - char *gitconfig_path = NULL; + char *gitconfig_path = NULL, *tagger = NULL; const char *tag_name, *commit_id_arg = NULL, *tagmsg = NULL; int ch, do_list = 0; @@ -6819,6 +6814,15 @@ cmd_tag(int argc, char *argv[]) if (error != NULL) goto done; + error = get_author(&tagger, repo, worktree); + if (error) + goto done; + if (worktree) { + /* Release work tree lock. */ + got_worktree_close(worktree); + worktree = NULL; + } + if (tagmsg) { error = apply_unveil(got_repo_get_path(repo), 0, NULL); if (error) @@ -6843,7 +6847,7 @@ cmd_tag(int argc, char *argv[]) goto done; } - error = add_tag(repo, worktree, tag_name, + error = add_tag(repo, tagger, tag_name, commit_id_str ? commit_id_str : commit_id_arg, tagmsg); } done: @@ -6858,6 +6862,7 @@ done: free(repo_path); free(gitconfig_path); free(commit_id_str); + free(tagger); return error; }