Commit Diff


commit - e77c4c9f24dccb34ff8c4f500b0764011635cff2
commit + 5166488913ca69fd4d6c284f8bee054b6bf1d073
blob - 5543614b4e88cd79cc2f037d2bb4c4ce72148758
blob + 78b75a9cb1e13a14d285c5a07338fb4f92220d0f
--- lib/worktree.c
+++ lib/worktree.c
@@ -576,11 +576,6 @@ got_worktree_checkout_files(struct got_worktree *workt
 		goto done;
 	}
 
-	err = got_opentemp_named(&new_fileindex_path, &findex, fileindex_path);
-	if (err)
-		goto done;
-
-
 	if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
 		err = got_error(GOT_ERR_NO_MEM);
@@ -588,6 +583,10 @@ got_worktree_checkout_files(struct got_worktree *workt
 		goto done;
 	}
 
+	err = got_opentemp_named(&new_fileindex_path, &findex, fileindex_path);
+	if (err)
+		goto done;
+
 	err = got_ref_resolve(&commit_id, repo, head_ref);
 	if (err)
 		goto done;