Skip to content

Commit c07abd6

Browse files
author
Carson Howard
committed
submodule: add better error handling to is_path_occupied
1 parent b282ca7 commit c07abd6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/submodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
176176
if ((error = git_path_to_dir(&dir)) < 0)
177177
goto out;
178178

179-
if ((error = git_index_find_prefix(NULL, index, dir.ptr)) == 0) {
179+
if ((error = git_index_find_prefix(NULL, index, dir.ptr)) < 0 && error != GIT_ENOTFOUND)
180+
goto out;
181+
182+
if (!error) {
180183
giterr_set(GITERR_SUBMODULE,
181184
"Directory '%s' already exists in the index", path);
182185
*occupied = true;

0 commit comments

Comments
 (0)