fail test if worktree cannot be removed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index bb8301d..1259b0c 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -77,17 +77,26 @@ remove_meta_file(const char *worktree_path, const char *name)
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);