For a .gitignore with this line:
git_status_foreach returns GIT_STATUS_IGNORED for files directly in foo/ but GIT_STATUS_WT_NEW for files in subdirectories of foo/.
Have you checked the new-error-handling branch?. The status has been improved by @arrbee. Cf. libgit2/libgit2#610
Looks like that should do it. Will reopen if it's still broken on merge.