sync
authorAlan Knowles <alan@roojs.com>
Wed, 20 Mar 2019 06:37:20 +0000 (14:37 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 20 Mar 2019 06:37:20 +0000 (14:37 +0800)
Git.vala
GitRepo.vala

index b4cc84c..6207008 100644 (file)
--- a/Git.vala
+++ b/Git.vala
@@ -186,9 +186,7 @@ namespace  GitLive {
                        
                        
                        this.repo.create_commit("HEAD", sig, sig, null, "Test Merge", new_tree, parents);
-       
-                       
-                       
+        
                        
                        
                }
@@ -219,9 +217,12 @@ namespace  GitLive {
                        var commits =   new Ggit.AnnotatedCommit[] { ac };
                        
                        this.repo.merge(commits, mo, co);
+                       
+                       var cfg = this.repo.get_config().snapshot();
+                       
                    var sig = new Ggit.Signature.now(
-                                       this.repo.get_config().get_string("user.name"),
-                                       this.repo.get_config().get_string("user.email")
+                                       cfg.get_string("user.name"),
+                                       cfg.get_string("user.email")
                        );
                        var new_head = this.repo.get_head();
                        var oid = new_head.get_target();
@@ -236,9 +237,8 @@ namespace  GitLive {
                        var parent = new_head.lookup() as Ggit.Commit;
                        Ggit.Commit[] parents =  new Ggit.Commit[] { parent };
                        
-                       this.repo.create_commit(this.head.get_name(), sig, sig, null, "Test Merge", new_tree, parents);
+                       this.repo.create_commit("refs/heads/" + this.head.get_name(), sig, sig, null, "Test Merge", new_tree, parents);
         
-               
                }
                
                
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;