sync
[gitlive] / GitRepo.vala
index d1ee645..987f495 100644 (file)
@@ -28,10 +28,10 @@ public class GitRepo : Object
     public GitBranch currentBranch;
     public Gee.HashMap<string,GitBranch> branches; // accessed in GitBranch..
        public RooTicket? activeTicket;
-    public  Gee.HashMap<string,GitRepo> cache;
-    public  Gee.HashMap<string,string> config_cache;
-    
+    public Gee.HashMap<string,GitRepo> cache;
+    public Gee.HashMap<string,string> config_cache;
     
+    private Ggit.Repository repo;
     
        public static GitRepo singleton()
     {
@@ -175,8 +175,13 @@ public class GitRepo : Object
                        cache.set( path, this);
        }
        
-       var r = this.git({ "remote" , "get-url" , "--push" , "origin"});
-       var uri = new Soup.URI(r);      
+       this.repo =  Ggit.Repository.open(GLib.File.new_for_path(path));
+       
+       var r = this.repo.lookup_remote("origin");
+       
+       
+       //var r = this.git({ "remote" , "get-url" , "--push" , "origin"});
+       var uri = new Soup.URI(r.get_url());            
        this.host = uri.get_host();
                this.init_config();
        
@@ -209,27 +214,30 @@ public class GitRepo : Object
     
     
     
-    public string get_config(string key) {
+    public string get_config(string key) 
+    {
     
        if (this.config_cache.has_key(key)) {
                //GLib.debug("get_config %s = '%s'", key, this.config_cache.get(key));
                return this.config_cache.get(key);
                }
        try {
-               var ret =   this.git({ "config" , "gitlive." + key }).strip();
-               this.config_cache.set(key, ret);
-               //GLib.debug("get_config %s = '%s'", key, ret);
+               var cfg = this.repo.get_config().snapshot();
+               var ret = cfg.get_string("gitlive." + key).strip();
                return ret;
        } catch (Error e) {
-               this.config_cache.set(key, "");
+               this.repo.get_config().set_string("gitlive." + key, "");
+               //this.config_cache.set(key, "");
                //GLib.debug("get_config (fail) %s = '%s'", key, "");
                return ""; // happens when there is nothing set...
        }
 
        }
-    public void set_config(string key, string value) {
-       this.git({ "config" , "gitlive." + key, value });
-       this.config_cache.set(key,value);
+    public void set_config(string key, string value) 
+    {
+       this.repo.get_config().set_string("gitlive." + key, value);
+       //this.git({ "config" , "gitlive." + key, value });
+       //this.config_cache.set(key,value);
        }
     
     public bool is_managed()
@@ -283,6 +291,7 @@ public class GitRepo : Object
     
        public void loadStatus()
        {
+               // status??/ 
                var r = this.git({ "status" , "--porcelain" });
                this.git_status = r;
                this.has_local_changes = r.length > 0;