Commit 675c7539c677a208d43573b3459ac144e7739b09

Stefan Sperling 2019-05-07T11:28:15

do status walk before opening base commit/tree

diff --git a/lib/worktree.c b/lib/worktree.c
index a6554be..c1378d1 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2261,6 +2261,13 @@ got_worktree_commit(struct got_object_id **new_commit_id,
 	if (err)
 		goto done;
 
+	err = got_worktree_status(worktree, relpath ? relpath : "",
+	    repo, collect_committables, &paths, NULL, NULL);
+	if (err)
+		goto done;
+
+	/* TODO: collect commit message if not specified */
+
 	err = got_object_open_as_commit(&base_commit, repo,
 	    worktree->base_commit_id);
 	if (err)
@@ -2270,13 +2277,6 @@ got_worktree_commit(struct got_object_id **new_commit_id,
 	if (err)
 		goto done;
 
-	err = got_worktree_status(worktree, relpath ? relpath : "",
-	    repo, collect_committables, &paths, NULL, NULL);
-	if (err)
-		goto done;
-
-	/* TODO: collect commit message if not specified */
-
 	/* TODO: walk base tree and patch it to create a new tree */
 	printf("committables:\n");
 	TAILQ_FOREACH(pe, &paths, entry) {