GNOME Bugzilla – Bug 747727
add helper to check if path is ignored
Last modified: 2019-02-22 03:51:38 UTC
Created attachment 301397 [details] [review] add git_ignore_path_is_ignored() wrapper https://libgit2.github.com/libgit2/#HEAD/group/ignore/git_ignore_path_is_ignored git_ignore_path_is_ignored() can be used to quickly check if a given path is ignored in the repository. I've attached a patch to add it to GgitRepository.
Review of attachment 301397 [details] [review]: See the inline comments. ::: libgit2-glib/ggit-repository.c @@ +117,3 @@ } +gboolean you are missing the documentation @@ +129,3 @@ + repo = _ggit_native_get (repository); + + if (repo != NULL) this will never fail if you already checked that is a repo @@ +131,3 @@ + if (repo != NULL) + { + git_ignore_path_is_ignored (&ret, repo, path); you should check the result and behave accordingly, see other methods for an example on how to wrap methods
Created attachment 301446 [details] [review] adds ggit_repository_path_is_ignored() add docs, check for libgit2 errors, remove superfluous check
Review of attachment 301446 [details] [review]: Just a couple of nitpicks. Feel free to fix them and push the patch. ::: libgit2-glib/ggit-repository.c @@ +140,3 @@ + + g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE); + g_return_val_if_fail (path != NULL, FALSE); I think you need a return also for the error? check the other methods since I think they have it @@ +143,3 @@ + + repo = _ggit_native_get (repository); + ret = git_ignore_path_is_ignored (&ignored, repo, path); you could put inline the _ggit_native_get to avoid having the extra local var
We don't need to check for error, because NULL is perfectly valid here. (We could pedantic and check for *error == NULL when provided, but I didn't see that anywhere else, and g_set_error*() will catch that anyway). Usually I keep a local just for debugging purposes, but I'm happy to remove it. We can just `p _ggit_native_get()` in gdb if ever required. Pushed to master, thanks!