X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=GitBranch.vala;h=e9964922c156b7a133061bdb9b643b1734dafc0f;hb=01af28a18150e1c30fd20ef32da736c7ceee80ef;hp=a61535280167710ba7ac9867530ad911500de3a9;hpb=8af91c12993083119e042f5410688358664336f0;p=gitlive diff --git a/GitBranch.vala b/GitBranch.vala index a6153528..e9964922 100644 --- a/GitBranch.vala +++ b/GitBranch.vala @@ -90,13 +90,26 @@ public class GitBranch : Object var r = repo.repo.enumerate_branches(Ggit.BranchType.LOCAL); while (r.next()) { + + + var br = new GitBranch(repo); var gbr = r.get() as Ggit.Branch; - repo.branches.set(gbr.get_name(), br); + if (!gbr.is_branch()) { + continue; + } + 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 +132,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; + } } @@ -127,8 +144,16 @@ public class GitBranch : Object if (remotes_used.get(rn)) { continue; } + if (repo.branches.has_key(rn)) { + GLib.debug("skip tracking branch - same name exists?"); + continue; + } // not clear how to do this yet... - repo.git( { "branch" ,"--track" , rn, "origin/" + rn} ); + try { + repo.git( { "branch" ,"--track" , rn, "origin/" + rn} ); + } catch (Error e) { + continue; // allow failure? + } var br = new GitBranch(repo); br.name = rn; br.lastrev = ""; // it's behind @@ -140,6 +165,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); + } @@ -263,10 +291,7 @@ public class GitBranch : Object return this.is_remote ? this.remote : this.name; } - public void create() - { - - } +// public void create() { } }