X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=GitRepo.vala;h=6108c1eebf7dbd66f0fe24e2c129515917d3c2f3;hb=55d94ffcc22b705da1d4149afd5d4cfb453136ba;hp=b1bb25f9f527471d2f4aea56c712103a5ce8bc69;hpb=27286f9959213043f98fae7d27bca610b62b93c2;p=gitlive diff --git a/GitRepo.vala b/GitRepo.vala index b1bb25f9..6108c1ee 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -347,33 +347,60 @@ public class GitRepo : Object } public bool createBranchNamed(string branchname) - { - - try { + { + + var stash = false; if (this.branches.has_key(branchname)) { // this is where it get's tricky... - - string[] cmd = { "ls-files" , "-m" }; // list the modified files.. - var ret = this.git(cmd); - var stash = ret.length> 1 ; - - - cmd = { "stash" }; - if (stash) { this.git(cmd); } - - cmd = { "checkout", branchname }; - this.git(cmd); - - cmd = { "merge", "master" }; - this.git(cmd); - - cmd = { "stash", "pop" }; - if (stash) { this.git(cmd); } - + try { + string[] cmd = { "ls-files" , "-m" }; // list the modified files.. + var ret = this.git(cmd); + stash = ret.length> 1 ; + + + cmd = { "stash" }; + if (stash) { this.git(cmd); } + + cmd = { "checkout", branchname }; + this.git(cmd); + } catch(Error e) { + GitMonitor.gitmonitor.pauseError(e.message); + return false; + + } + try { + string[] cmd = { "merge", "master" }; + this.git(cmd); + } catch(Error e) { + try { + string[] cmd = { "mergetool" }; + this.git(cmd); + cmd = { "commit", "-m" , "Fix merge conflicts from master" }; + this.git(cmd); + } catch(Error ee) { + GitMonitor.gitmonitor.pauseError(ee.message); + return false; + } + } + try { + string[] cmd = { "stash", "pop" }; + if (stash) { this.git(cmd); } + } catch(Error ee) { + GitMonitor.gitmonitor.pauseError(ee.message); + return false; + } + } else { - string[] cmd = { "checkout", "-b" , branchname }; - this.git(cmd); + try { + + string[] cmd = { "checkout", "-b" , branchname }; + this.git(cmd); + } catch(Error ee) { + GitMonitor.gitmonitor.pauseError(ee.message); + return false; + } + } var notification = new Notify.Notification( "Changed to branch %s".printf(branchname), @@ -386,11 +413,7 @@ public class GitRepo : Object notification.show(); - } catch(Error e) { - GitMonitor.gitmonitor.pauseError(e.message); - return false; - } this.loadBranches(); // update branch list... GitMonitor.gitmonitor.runQueue(); // commit any outstanding... return true;