private static void GitGetFiles(string wcRoot, GitStatusSet statusSet) { var git = Git.FindGit(); if (git == null) return; var runner = new ProcessRunner(); runner.WorkingDirectory = wcRoot; runner.LogStandardOutputAndError = false; runner.OutputLineReceived += delegate (object sender, LineReceivedEventArgs e) { if (!string.IsNullOrEmpty(e.Line)) { statusSet.AddEntry(e.Line, GitStatus.OK); } }; var command = "ls-files"; var hasErrors = false; runner.ErrorLineReceived += delegate (object sender, LineReceivedEventArgs e) { if (!hasErrors) { hasErrors = true; GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command); } GitMessageView.AppendLine(e.Line); }; runner.Start(git, command); runner.WaitForExit(); }
private static void GitGetStatus(string wcRoot, GitStatusSet statusSet) { var git = Git.FindGit(); if (git == null) return; var command = "status --porcelain --untracked-files=no"; var hasErrors = false; var runner = new ProcessRunner(); runner.WorkingDirectory = wcRoot; runner.LogStandardOutputAndError = false; runner.OutputLineReceived += delegate (object sender, LineReceivedEventArgs e) { if (!string.IsNullOrEmpty(e.Line)) { var m = StatusParseRegex.Match(e.Line); if (m.Success) { statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value)); } else { if (!hasErrors) { // in front of first output line, print the command line we invoked hasErrors = true; GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command); } GitMessageView.AppendLine("unknown output: " + e.Line); } } }; runner.ErrorLineReceived += delegate (object sender, LineReceivedEventArgs e) { if (!hasErrors) { hasErrors = true; GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command); } GitMessageView.AppendLine(e.Line); }; runner.Start(git, command); runner.WaitForExit(); }