Skip to content

Commit b254a58

Browse files
committed
sysdir: fix formatting error message with NULL string
When trying to the template dir, we pass in a `NULL` pointer for the filename. That's perfectly fine, but if we're failing to find the template directory then we'll creat an error message with the `NULL` pointer passed in. Fix the issue by setting different error messages based on whether the filename is given or not. This even makes sense, as we're not searching for a file in case we have no `name`, but for a directory. So the error would've been misleading anyway.
1 parent 37ae007 commit b254a58

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/sysdir.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,11 @@ static int git_sysdir_find_in_dirlist(
298298
}
299299

300300
done:
301+
if (name)
302+
git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
303+
else
304+
git_error_set(GIT_ERROR_OS, "the %s directory doesn't exist", label);
301305
git_buf_dispose(path);
302-
git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
303306
return GIT_ENOTFOUND;
304307
}
305308

0 commit comments

Comments
 (0)