Skip to content

Commit 3b83bda

Browse files
author
Vicent Martí
committed
Merge pull request libgit2#470 from schu/test-helpers-no-assert
test_helpers: do not rely on assert
2 parents f8e8c8d + ec90794 commit 3b83bda

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_helpers.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ int loose_object_mode(const char *repository_folder, git_object *object)
116116
struct stat st;
117117

118118
locate_loose_object(repository_folder, object, &object_path, NULL);
119-
assert(p_stat(object_path, &st) == 0);
119+
if (p_stat(object_path, &st) < 0)
120+
return 0;
120121
free(object_path);
121122

122123
return st.st_mode;
@@ -138,7 +139,8 @@ int loose_object_dir_mode(const char *repository_folder, git_object *object)
138139
}
139140
}
140141

141-
assert(p_stat(object_path, &st) == 0);
142+
if (p_stat(object_path, &st) < 0)
143+
return 0;
142144
free(object_path);
143145

144146
return st.st_mode;

0 commit comments

Comments
 (0)