[anjuta/libgit2-glib: 5/14] git: Add a method for getting the current git repository



commit 93b46616c5dfa7a3592ea2f33cfc279286092ba2
Author: James Liggett <jrliggett cox net>
Date:   Tue Jul 23 14:09:28 2013 -0700

    git: Add a method for getting the current git repository

 plugins/git/git-command.c        |    6 +++++-
 plugins/git/git-command.h        |    2 ++
 plugins/git/git-status-command.c |   30 +++++++++++++-----------------
 3 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/plugins/git/git-command.c b/plugins/git/git-command.c
index f83c608..bc21fd5 100644
--- a/plugins/git/git-command.c
+++ b/plugins/git/git-command.c
@@ -117,4 +117,8 @@ git_command_class_init (GitCommandClass *klass)
                                                                                                              
    G_PARAM_WRITABLE));
 }
 
-
+GgitRepository *
+git_command_get_repository (GitCommand *self)
+{
+       return self->priv->repository;
+}
diff --git a/plugins/git/git-command.h b/plugins/git/git-command.h
index 7538e1a..4ef3a3b 100644
--- a/plugins/git/git-command.h
+++ b/plugins/git/git-command.h
@@ -52,6 +52,8 @@ struct _GitCommand
 
 GType git_command_get_type (void) G_GNUC_CONST;
 
+GgitRepository *git_command_get_repository (GitCommand *self);
+
 G_END_DECLS
 
 #endif /* _GIT_COMMAND_H_ */
diff --git a/plugins/git/git-status-command.c b/plugins/git/git-status-command.c
index eef39e8..0d03bc7 100644
--- a/plugins/git/git-status-command.c
+++ b/plugins/git/git-status-command.c
@@ -78,28 +78,26 @@ git_status_command_run (AnjutaTask *task)
        GgitStatusOption option_flags;
        const gchar *paths[2];
 
-       self = GIT_STATUS_COMMAND (task);;
+       self = GIT_STATUS_COMMAND (task);
+       repository = git_command_get_repository (GIT_COMMAND (task));
 
-       g_object_get (self, "repository", &repository, NULL);
+       g_return_if_fail (repository);
 
-       if (repository)
-       {
-               option_flags = 0;
+       option_flags = 0;
 
-               if (self->priv->sections & GIT_STATUS_SECTION_UNTRACKED)
-                       option_flags |= GGIT_STATUS_OPTION_INCLUDE_UNTRACKED;
+       if (self->priv->sections & GIT_STATUS_SECTION_UNTRACKED)
+               option_flags |= GGIT_STATUS_OPTION_INCLUDE_UNTRACKED;
 
-               paths[0] = self->priv->path;
-               paths[1] = NULL;
+       paths[0] = self->priv->path;
+       paths[1] = NULL;
 
-               options = ggit_status_options_new (option_flags, 0, paths);
+       options = ggit_status_options_new (option_flags, 0, paths);
 
-               ggit_repository_file_status_foreach (repository, options, 
-                                                    (GgitStatusCallback) git_status_command_status_callback,
-                                                    self, NULL);
+       ggit_repository_file_status_foreach (repository, options, 
+                                            (GgitStatusCallback) git_status_command_status_callback,
+                                            self, NULL);
 
-               ggit_status_options_free (options);
-       }
+       ggit_status_options_free (options);
 }
 
 static void
@@ -122,8 +120,6 @@ git_status_command_new (GitStatusSections sections, const gchar *path)
        
        self->priv->sections = sections;
        self->priv->path = g_strdup (path);
-
-       g_print ("Given path: %s\n", path);
        
        return GIT_COMMAND (self);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]