From: Alan Knowles Date: Wed, 27 Mar 2019 03:42:17 +0000 (+0800) Subject: GitRepo.vala X-Git-Url: http://git.roojs.org/?p=gitlive;a=commitdiff_plain;h=dc24fce063ca75ff820e13353ff9b9b7c5bba546 GitRepo.vala --- diff --git a/GitRepo.vala b/GitRepo.vala index 73866d7a..08917693 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -683,11 +683,32 @@ public class GitRepo : Object GitMonitor.gitmonitor.pauseError(ee.message); return "Error getting diff"; } - - + } + public string diffWorking() + { + var cb = this.getCurrentBranch(); + GLib.debug("Calling diff working"); + var diff = new Ggit.Diff.tree_to_workdir(this.repo, cb.getTree(), new Ggit.DiffOptions()); + var ret = ""; + diff.print(Ggit.DiffFormatType.PATCH, (delta, hunk, line) => { + switch(line.get_origin()) { + case Ggit.DiffLineType.ADDITION: ret+="+"; break; + case Ggit.DiffLineType.DELETION: ret+="-";break; + case Ggit.DiffLineType.CONTEXT: ret+=" ";break; + case Ggit.DiffLineType.HUNK_HDR: break; + case Ggit.DiffLineType.FILE_HDR: break; + default: ret+=" ";break; + } + ret += " " + line.get_text() ; + return 0; + }); + GLib.debug("returning %s", ret); + return ret; + } + /** * add: