After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 747727 - add helper to check if path is ignored
add helper to check if path is ignored
Status: RESOLVED FIXED
Product: libgit2-glib
Classification: Core
Component: General
git master
Other Linux
: Normal normal
: ---
Assigned To: gitg-maint
gitg-maint
Depends on:
Blocks:
 
 
Reported: 2015-04-12 08:43 UTC by Christian Hergert
Modified: 2019-02-22 03:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add git_ignore_path_is_ignored() wrapper (1.92 KB, patch)
2015-04-12 08:43 UTC, Christian Hergert
none Details | Review
adds ggit_repository_path_is_ignored() (2.55 KB, patch)
2015-04-13 09:19 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2015-04-12 08:43:34 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.
Comment 1 Ignacio Casal Quinteiro (nacho) 2015-04-12 08:56:27 UTC
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
Comment 2 Christian Hergert 2015-04-13 09:19:16 UTC
Created attachment 301446 [details] [review]
adds ggit_repository_path_is_ignored()

add docs, check for libgit2 errors, remove superfluous check
Comment 3 Ignacio Casal Quinteiro (nacho) 2015-04-13 09:39:23 UTC
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
Comment 4 Christian Hergert 2015-04-13 18:51:43 UTC
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!