sync
[gitlive] / GitBranch.vala
index 58da00f..20e36fd 100644 (file)
@@ -92,11 +92,18 @@ public class GitBranch : Object
                while (r.next()) {
                        var br = new GitBranch(repo);
                        var gbr = r.get() as Ggit.Branch;
-                       repo.branches.set(gbr.get_name(), br);
+
                        br.active = gbr.is_head();
                        br.name = gbr.get_name();
                        br.lastrev = gbr.get_target().to_string();
-                       var rname = gbr.get_upstream() != null ? gbr.get_upstream().get_name() : "";
+                       string rname ;
+                       try {
+                               rname = gbr.get_upstream() != null ? gbr.get_upstream().get_name() : "";
+                       } catch(Error e) {
+                               GLib.debug("Skip branch = got error");
+                               continue;
+                       }
+                       repo.branches.set(gbr.get_name(), br);                  
                        if (rname.has_prefix("refs/remotes/origin/")) {
                                rname = rname.substring(20);
                                if (remotes.has_key(rname)) {
@@ -119,6 +126,10 @@ public class GitBranch : Object
                                // age?
                                // behind or infront..
                        }
+                       if (br.active) {
+                               GLib.debug("repo: %s currentBranch = %s", repo.name, br.name);
+                               repo.currentBranch = br;
+                       }
                        
                }
                
@@ -140,6 +151,9 @@ public class GitBranch : Object
                        repo.branches.set(rn, br);
                        
                }
+               if (repo.currentBranch == null) {
+                       GLib.error("could not find active Branch for %s", repo.name);
+               }