[libgit2-glib] ggit_tree_get_by_file: return null if path does not exists
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] ggit_tree_get_by_file: return null if path does not exists
- Date: Sun, 13 Jan 2013 18:57:53 +0000 (UTC)
commit df5ca1c8027dd84634336da4c385c7d1e7e7513b
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date: Sun Jan 13 19:57:34 2013 +0100
ggit_tree_get_by_file: return null if path does not exists
libgit2-glib/ggit-tree.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/libgit2-glib/ggit-tree.c b/libgit2-glib/ggit-tree.c
index ec834a5..33b02f8 100644
--- a/libgit2-glib/ggit-tree.c
+++ b/libgit2-glib/ggit-tree.c
@@ -142,16 +142,23 @@ ggit_tree_get_by_file (GgitTree *tree,
{
git_tree *t;
gchar *path;
- GgitTreeEntry *entry;
+ GgitTreeEntry *entry = NULL;
+ const git_tree_entry *tree_entry;
g_return_val_if_fail (GGIT_IS_TREE (tree), NULL);
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
t = _ggit_native_get (tree);
path = g_file_get_path (file);
- entry = _ggit_tree_entry_wrap (git_tree_entry_byname (t, path));
+ tree_entry = git_tree_entry_byname (t, path);
g_free (path);
+ if (tree_entry != NULL)
+ {
+ entry = _ggit_tree_entry_wrap (tree_entry);
+ }
+
return entry;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]