remotes.set(rn.substring(11), rh.get_oid());
remotes_used.set(rn.substring(11), false);
- }
+ }
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)) {
// age?
// behind or infront..
}
+ if (br.active) {
+ GLib.debug("repo: %s currentBranch = %s", repo.name, br.name);
+ repo.currentBranch = br;
+ }
}
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
+ br.remoterev = remotes.get(rn).to_string();
+ br.remote = rn;
+ br.ahead = 0;
+ br.behind = 1;
+ // behind/ahead == 0...
+ repo.branches.set(rn, br);
}
+ if (repo.currentBranch == null) {
+ GLib.error("could not find active Branch for %s", repo.name);
+ }
+
-
-
+ /*
// repo.git( { "fetch", "-a" } ); == done async before...
string[] cmd = { "branch", "--no-color", "--verbose", "--no-abbrev" , "-a" };
br.name = newname;
local.set(br.name, br);
}
-
+ */
/*
this bit of the code tries to turn a local branch into a track of a remote one.
-- that's probably not a good idea.
name = name.replace("/", ".");
}
- */
+
repo.branches = local;
-
+ */
}
return this.is_remote ? this.remote : this.name;
}
- public void create()
- {
-
- }
+// public void create() { }
}