Commit 087fb88cd8e5db9d9fdcf25440bced2d15fe55c8

Stefan Sperling 2019-08-04T12:52:33

call get_worktree_paths_from_argv() after unveil(2) where possible

diff --git a/got/got.c b/got/got.c
index 0b09fb1..6016098 100644
--- a/got/got.c
+++ b/got/got.c
@@ -1161,10 +1161,6 @@ cmd_update(int argc, char *argv[])
 	if (error)
 		goto done;
 
-	error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
-	if (error)
-		goto done;
-
 	error = got_repo_open(&repo, got_worktree_get_repo_path(worktree));
 	if (error != NULL)
 		goto done;
@@ -1174,6 +1170,10 @@ cmd_update(int argc, char *argv[])
 	if (error)
 		goto done;
 
+	error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
+	if (error)
+		goto done;
+
 	error = got_ref_open(&head_ref, repo, branch_name ? branch_name :
 	    got_worktree_get_head_ref_name(worktree), 0);
 	if (error != NULL)
@@ -2458,10 +2458,6 @@ cmd_status(int argc, char *argv[])
 	if (error != NULL)
 		goto done;
 
-	error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
-	if (error)
-		goto done;
-
 	error = got_repo_open(&repo, got_worktree_get_repo_path(worktree));
 	if (error != NULL)
 		goto done;
@@ -2471,6 +2467,10 @@ cmd_status(int argc, char *argv[])
 	if (error)
 		goto done;
 
+	error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
+	if (error)
+		goto done;
+
 	error = got_worktree_status(worktree, &paths, repo, print_status, NULL,
 	    check_cancelled, NULL);
 done:
@@ -3312,10 +3312,6 @@ cmd_commit(int argc, char *argv[])
 	if (error)
 		goto done;
 
-	error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
-	if (error)
-		goto done;
-
 	error = got_repo_open(&repo, got_worktree_get_repo_path(worktree));
 	if (error != NULL)
 		goto done;
@@ -3332,6 +3328,10 @@ cmd_commit(int argc, char *argv[])
 	if (error)
 		goto done;
 
+	error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
+	if (error)
+		goto done;
+
 	cl_arg.editor = editor;
 	cl_arg.cmdline_log = logmsg;
 	cl_arg.worktree_path = got_worktree_get_root_path(worktree);