Commit Diff


commit - b18d25dfcd29e2fc8955510f7aad77297f0a61c7
commit + 45d8e5fd73c78e74a93ad22fe7161f3478f8320a
blob - bb8301d05f1dc748b1d471a60522067e29e47e7d
blob + 1259b0cd6d3ca9eb4574032f91c137a2b4c2cf97
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
@@ -77,17 +77,26 @@ remove_meta_file(const char *worktree_path, const char
 	return 1;
 }
 
-static void
+static int
 remove_worktree(const char *worktree_path)
 {
-	remove_meta_file(worktree_path, GOT_REF_HEAD);
-	remove_meta_file(worktree_path, GOT_WORKTREE_FILE_INDEX);
-	remove_meta_file(worktree_path, GOT_WORKTREE_REPOSITORY);
-	remove_meta_file(worktree_path, GOT_WORKTREE_PATH_PREFIX);
-	remove_meta_file(worktree_path, GOT_WORKTREE_LOCK);
-	remove_meta_file(worktree_path, GOT_WORKTREE_FORMAT);
-	remove_got_dir(worktree_path);
-	rmdir(worktree_path);
+	if (!remove_meta_file(worktree_path, GOT_REF_HEAD))
+		return 0;
+	if (!remove_meta_file(worktree_path, GOT_WORKTREE_FILE_INDEX))
+		return 0;
+	if (!remove_meta_file(worktree_path, GOT_WORKTREE_REPOSITORY))
+		return 0;
+	if (!remove_meta_file(worktree_path, GOT_WORKTREE_PATH_PREFIX))
+		return 0;
+	if (!remove_meta_file(worktree_path, GOT_WORKTREE_LOCK))
+		return 0;
+	if (!remove_meta_file(worktree_path, GOT_WORKTREE_FORMAT))
+		return 0;
+	if (!remove_got_dir(worktree_path))
+		return 0;
+	if (rmdir(worktree_path) == -1)
+		return 0;
+	return 1;
 }
 
 static int
@@ -144,8 +153,10 @@ worktree_init(const char *repo_path)
 		goto done;
 	if (!check_meta_file_exists(worktree_path, GOT_WORKTREE_FORMAT))
 		goto done;
+
+	if (!remove_worktree(worktree_path))
+		goto done;
 	ok = 1;
-	remove_worktree(worktree_path);
 done:
 	if (head_ref)
 		got_ref_close(head_ref);