Commit Diff


commit - 82c78e96f11e4190c3d91f18122df14e30347300
commit + 021334f93ef590f85da3fa9312fcc519eb6b2d25
blob - 65551dc9c9ab16277bcd21dddd49e8bd176e6da6
blob + 4719e5dbdd776ed4b252cda4a1e43672e360f591
--- got/got.c
+++ got/got.c
@@ -7478,11 +7478,6 @@ cmd_tag(int argc, char *argv[])
 			if (error)
 				goto done;
 		}
-		if (worktree) {
-			/* Release work tree lock. */
-			got_worktree_close(worktree);
-			worktree = NULL;
-		}
 
 		if (tagmsg) {
 			if (signer_id) {
@@ -7513,6 +7508,12 @@ cmd_tag(int argc, char *argv[])
 				goto done;
 		}
 
+		if (worktree) {
+			/* Release work tree lock. */
+			got_worktree_close(worktree);
+			worktree = NULL;
+		}
+
 		error = add_tag(repo, tagger, tag_name,
 		    commit_id_str ? commit_id_str : commit_id_arg, tagmsg,
 		    signer_id, verbosity);