projects
/
gitlive
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
NewBranch.bjs
[gitlive]
/
GitBranch.vala
diff --git
a/GitBranch.vala
b/GitBranch.vala
index
1ff550a
..
c08721b
100644
(file)
--- a/
GitBranch.vala
+++ b/
GitBranch.vala
@@
-85,18
+85,31
@@
public class GitBranch : Object
remotes.set(rn.substring(11), rh.get_oid());
remotes_used.set(rn.substring(11), false);
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 r = repo.repo.enumerate_branches(Ggit.BranchType.LOCAL);
while (r.next()) {
+
+
+
var br = new GitBranch(repo);
var gbr = r.get() as Ggit.Branch;
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();
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)) {
if (rname.has_prefix("refs/remotes/origin/")) {
rname = rname.substring(20);
if (remotes.has_key(rname)) {
@@
-104,21
+117,32
@@
public class GitBranch : Object
br.remoterev = remotes.get(rname).to_string();
remotes_used.set(rname,true);
size_t ahead, behind;
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);
+ }
+
}
// age?
// behind or infront..
}
}
// age?
// behind or infront..
}
+ if (br.active) {
+ GLib.debug("repo: %s currentBranch = %s", repo.name, br.name);
+ repo._currentBranch = br;
+ }
}
}
@@
-127,8
+151,16
@@
public class GitBranch : Object
if (remotes_used.get(rn)) {
continue;
}
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...
// 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
var br = new GitBranch(repo);
br.name = rn;
br.lastrev = ""; // it's behind
@@
-140,6
+172,10
@@
public class GitBranch : Object
repo.branches.set(rn, br);
}
repo.branches.set(rn, br);
}
+
+ if (repo._currentBranch == null) {
+ GLib.error("could not find active Branch for %s", repo.name);
+ }
@@
-263,10
+299,7
@@
public class GitBranch : Object
return this.is_remote ? this.remote : this.name;
}
return this.is_remote ? this.remote : this.name;
}
- public void create()
- {
-
- }
+// public void create() { }
}
}