Git.vala
authorAlan Knowles <alan@roojs.com>
Thu, 14 Mar 2019 09:09:59 +0000 (17:09 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 14 Mar 2019 09:09:59 +0000 (17:09 +0800)
Git.vala

index 106cabc..f65eeab 100644 (file)
--- a/Git.vala
+++ b/Git.vala
@@ -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 head = a.repo.get_head();
+       var parent = head.lookup() as Ggit.Commit;
+       Ggit.Commit[] parents = (parent == null) ? 
+               new Ggit.Commit[] {} :
+               new Ggit.Commit[] { parent };
+
+
+                       var new_tree = a.repo.lookup(treeoid,typeof (Ggit.Tree))  as   Ggit.Tree;
+                       
+                       var sig = new Ggit.Signature.now("Alan Knowles", "alan@roojs.com");
+                       a.repo.create_commit("HEAD", sig, sig, null, "test commit " + str, new_tree, parents);
+       
                        
-//                     noid = a.next()
-       //              while (noid != null) {
-                               
-                               
-       //                      noid = a.next();
-       //              }