Fix #5662 - Gitlive - create a tracking branch
authorAlan Knowles <alan@roojs.com>
Tue, 15 Jan 2019 09:10:29 +0000 (17:10 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 15 Jan 2019 09:10:29 +0000 (17:10 +0800)
GitBranch.vala

index a30808b..84a8331 100644 (file)
@@ -103,7 +103,7 @@ public class GitBranch : Object
                    branches.get(lname).remote = rname;
             }
             
-            if (!branches.has_key(rname)) {
+            if (!branches.has_key(rname) || !branches.has_key(lname)  ) {
                     continue;
             }
             branches.get(lname).remoterev =  branches.get(rname).lastrev;
@@ -111,8 +111,23 @@ public class GitBranch : Object
                 
             branches.get(rname).name = lname;
         }
-        foreach(var br in local.values) {
+        foreach(var br in branches.values) {
                GLib.debug("BRANCH:\n%s\n" , br.toString());
+               if (br.name.length > 0 || ! /^remotes\/origin\//.match(br.remote)) {
+                       GLib.debug("SKIP - track exists");
+                       continue;
+               }
+               var newname = br.remote.replace("remotes/origin/","");
+               if (branches.has_key(newname)) {
+                       GLib.debug("SKIP - have branch already");
+                       continue;
+                       }
+                   
+                
+               repo.git(  { "branch" ,"--track" , newname,  "origin/" + newname} ); 
+               //
+               br.name  = newname;
+               local.set(br.name, br);
         }
         
         /*