Git.vala
[gitlive] / Git.vala
index 106cabc..f28f54a 100644 (file)
--- a/Git.vala
+++ b/Git.vala
@@ -1,5 +1,5 @@
 
-// valac -o /tmp/ggit Git.vala --pkg libgit2-glib-1.0 --pkg libsoup-2.4 -pkg gee-0.8 -g
+// valac -o /tmp/ggit Git.vala --pkg libgit2-glib-1.0 --pkg libsoup-2.4 --pkg gee-0.8 -g
 
 
 
@@ -157,13 +157,31 @@ namespace  GitLive {
                                GLib.debug("%d: %s, %s", line.get_new_lineno(), line.get_origin().to_string(), line.get_text());
                                return 0;
                        });
+                       // let's try a merge..
+                       var mo = new Ggit.MergeOptions();
+                       mo.set_file_favor(Ggit.MergeFileFavor.THEIRS);
+                       var ix = this.repo.merge_trees(null, master_tree, head_tree, mo);
+                       
+                       if (ix.has_conflicts()) {
+                               GLib.debug("merge has conflicts");
+                               return;
+                       }
+                        var treeoid = ix.write_tree();
+                        
+                        
+                         
+                       var parents =   new Ggit.Commit[] { master_commit };
+
+
+                       var new_tree = this.repo.lookup(treeoid,typeof (Ggit.Tree))  as   Ggit.Tree;
+                       
+                       var sig = new Ggit.Signature.now(
+                                       this.repo.get_config().get_string("user.name"),
+                                       this.repo.get_config().get_string("user.email")
+                       );
+                       this.repo.create_commit("HEAD", sig, sig, null, "Test Merge", new_tree, parents);
+       
                        
-//                     noid = a.next()
-       //              while (noid != null) {
-                               
-                               
-       //                      noid = a.next();
-       //              }