Uncommited changes synced
[gitlive] / GitBranch.vala
index e996492..6a2dfa1 100644 (file)
@@ -59,7 +59,11 @@ public class GitBranch : Object
                this.repo = repo;
        }
        
-       
+       public Ggit.Tree getTree()
+       {
+               var br = this.repo.repo.lookup_branch(this.name,Ggit.BranchType.LOCAL);
+               return this.repo.repo.lookup_commit(br.get_target()).get_tree();
+       }
        
 
        public static  void loadBranches(GitRepo repo)
@@ -117,15 +121,22 @@ public class GitBranch : Object
                                        br.remoterev = remotes.get(rname).to_string();
                                        remotes_used.set(rname,true);
                                        size_t ahead, behind;
-                                       repo.repo.get_ahead_behind(
-                                               gbr.get_target(),
-                                               remotes.get(rname),
-                                               out ahead,
-                                               out behind
-                                       );
-                                       br.ahead = (int)ahead;
-                                       br.behind = (int) behind;
+                                       br.behind = 1;
+                                       
+                                       try {
+                                               repo.repo.get_ahead_behind(
+                                                       gbr.get_target(),
+                                                       remotes.get(rname),
+                                                       out ahead,
+                                                       out behind
+                                               );
+                                               br.ahead = (int)ahead;
+                                               br.behind = (int) behind;
 
+                                       } catch(Error e) {
+                                               GLib.debug("we probably need to fetch... %s", repo.name);
+                                       }
+                                       
                                }
                                 
                                
@@ -134,7 +145,7 @@ public class GitBranch : Object
                        }
                        if (br.active) {
                                GLib.debug("repo: %s currentBranch = %s", repo.name, br.name);
-                               repo.currentBranch = br;
+                               repo._currentBranch = br;
                        }
                        
                }
@@ -165,7 +176,8 @@ public class GitBranch : Object
                        repo.branches.set(rn, br);
                        
                }
-               if (repo.currentBranch == null) {
+
+               if (repo._currentBranch == null) {
                        GLib.error("could not find active Branch for %s", repo.name);
                }