Ggit.init();
var a = new GitLive.Repo("/home/alan/gitlive/gitlive");
- a.branches();
+ a.loadBranches();
+ a.fetchAll();
+ //
/*
var a = new GitLive.Repo("/home/alan/git/test1-clone");
//a.fetchAll();
}
- public Gee.ArrayList<Ggit.Branch> branches()
+ Gee.ArrayList<Ggit.Branch> branches = null;
+ public void loadBranches()
{
- var ret = new Gee.ArrayList<Ggit.Branch>();
+ this.branches = new Gee.ArrayList<Ggit.Branch>();
var r = this.repo.enumerate_branches(Ggit.BranchType.LOCAL);
var br = r.get() as Ggit.Branch;
var head = this.repo.revparse("refs/heads/" + br.get_name() ).get_id();
var rhead = this.repo.revparse(br.get_upstream().get_name() ).get_id();
- GLib.debug("got branch: name = %s upstream = %s oid = %s roid= %s",
+ GLib.debug("got branch: name = %s upstream = %s oid = %s ",
br.get_name(), br.get_upstream().get_name(),
- head.to_string(), rhead.to_string());
-
+ head.to_string());
+ this.branches.add(br);
}
-
- return ret;
+
+ }
+ Ggit.Branch? getBranch(string remote_name, string remote_branch_name)
+ {
+
+ var target = remote_branch_name.replace("refs/heads/", remote_name+"/") .replace("refs/remotes/", "");
+
+
+ foreach(var br in this.branches) {
+ // GLib.debug("test:%s=%s", br.get_upstream().get_shorthand() , target);
+ if ( br.get_upstream().get_shorthand() == target) {
+ return br;
+ }
+
+ }
+ //GLib.debug("missing %s", remote_branch_name);
+ return null;
}
+
+
public void fetchAll()
{
// remotes probably will not work with http auth..
return;
}
- var heads = this.remote.list();
+ var heads = r.list();
foreach(var rh in heads) {
-
+ var br = this.getBranch(n, rh.get_name());
+
+ GLib.debug("got heads: name=%s rev=%s localrev=%s",
+ rh.get_name(),
+ rh.get_oid().to_string(),
+ br == null ? "?": this.repo.revparse(br.get_name() ).get_id().to_string()
+ );
}