sync
authorAlan Knowles <alan@roojs.com>
Wed, 13 Mar 2019 11:02:36 +0000 (19:02 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 13 Mar 2019 11:02:36 +0000 (19:02 +0800)
Git.vala
config1.builder

index 07c6e74..22cb679 100644 (file)
--- a/Git.vala
+++ b/Git.vala
@@ -20,6 +20,8 @@ void main()
        Ggit.init();
        
        var a = new GitLive.Repo("/home/alan/gitlive/gitlive");
+       a.walkDiff();
+       return;
        a.is_managed();
        a.is_autocommit();
        a.loadLocalBranches();
@@ -61,6 +63,7 @@ namespace  GitLive {
 
        public class Repo : Object {
 
+               string name = "";
                public Ggit.Repository  repo;
                Callbacks callbacks;
 
@@ -114,15 +117,64 @@ namespace  GitLive {
                }
                public void set_autocommit(bool val)
                {
-                       this.repo.get_config().set_int32("gitlive.autocommit", val ? "1" : "0");
+                       this.repo.get_config().set_int32("gitlive.autocommit", val ? 1 : 0);
                
                }
                 
+               public void walkDiff()
+               {
+                       this.loadLocalBranches();
+                       
+                       var oid =  this.repo.revparse(this.head.get_name() ).get_id()  ;
+                       var moid =  this.repo.revparse("refs/heads/master" ).get_id()  ;
+                       
+                       var a = new Ggit.RevisionWalker(this.repo);
+                       a.set_sort_mode(Ggit.SortMode.TOPOLOGICAL);
+                       a.push(oid);
+                       a.hide(moid);
+                       var last = oid;
+                       for (var noid = a.next(); noid != null; noid= a.next()) {
+                               //var commit = this.repo.lookup(noid, typeof(Ggit.Commit)) as Ggit.Commit;
+                               GLib.debug("rev: %s",
+                                       noid.to_string()
+                               );
+                               last = noid;
+                       }
+                       var commit = this.repo.lookup(last, typeof(Ggit.Commit)) as Ggit.Commit;
+                       var parent = commit.get_parents();
+                       GLib.debug("parent = %s", parent.get_id(0).to_string());
+                       var master_rev =  parent.get_id(0);
+                       var master_commit  = this.repo.lookup(master_rev, typeof(Ggit.Commit)) as Ggit.Commit;
+                       
+                       var head_commit = this.repo.lookup(oid, typeof(Ggit.Commit)) as Ggit.Commit;
+                       
+                       var master_tree = master_commit.get_tree();
+                       var head_tree = head_commit.get_tree();
+                       
+                       var diff = new Ggit.Diff.tree_to_tree(this.repo, master_tree, head_tree, new Ggit.DiffOptions());
+                       
+                       diff.print(Ggit.DiffFormatType.PATCH, ( delta,  hunk,  line) => {
+                               GLib.debug("%d: %s, %s", line.get_new_lineno(), line.get_origin().to_string(), line.get_text());
+                               return 1;
+                       });
+                       
+//                     noid = a.next()
+       //              while (noid != null) {
+                               
+                               
+       //                      noid = a.next();
+       //              }
+                       
+                       
+                       
+               }
+               
+               /*
                public bool doMergeClose(string commit_message)
                {
                        this.loadLocalBranches(true);
                        var oldbranch = this.head.get_name();
-            
+            // going to asume this is merge trees..
                           string [] cmd = { "merge",   "--squash",  oldbranch };
                           this.git( cmd );
                           cmd = { "commit",   "-a" , "-m",  commit_message };
@@ -141,6 +193,8 @@ namespace  GitLive {
                        notification.show();   
                
                
+               }
+               */
                
                
                public bool is_auto_branch ()
index a2d5e10..a62e422 100644 (file)
@@ -5,7 +5,6 @@
         "execute_args" : "-g",
         "target_bin" : "/tmp/gitlive",
         "sources" : [
-            "..//gitlive/Gitlive.vala",
             "..//gitlive/GitMonitor.vala",
             "..//gitlive/GitRepo.vala",
             "..//gitlive/Monitor.vala",