From 3ecd8cbc62126f74e0003dded7daa21439f63be1 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 8 Apr 2008 02:53:01 -0400 Subject: [PATCH] Monitor local git-upload-pack children for stderr output If a locally forked git-upload-pack has issues it will print messages to stderr, to tell us what went wrong. Rather than eating these we display them on our own stderr (which may be buried in the eclipse log file, but is at least still recorded) so we can better debug any issue we may have. We also use the thread that copies stderr->stderr to reap back the child process since the API doesn't properly support that notion. Signed-off-by: Shawn O. Pearce --- .../jgit/fetch/LocalGitProtocolFetchClient.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/org.spearce.jgit/src/org/spearce/jgit/fetch/LocalGitProtocolFetchClient.java b/org.spearce.jgit/src/org/spearce/jgit/fetch/LocalGitProtocolFetchClient.java index 9d8e923c..e975c9aa 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/fetch/LocalGitProtocolFetchClient.java +++ b/org.spearce.jgit/src/org/spearce/jgit/fetch/LocalGitProtocolFetchClient.java @@ -59,6 +59,37 @@ public class LocalGitProtocolFetchClient extends FullFetchClient { new String[] { "git-upload-pack", "." }, null, remoteGitDir); final InputStream inputStream = process.getInputStream(); final OutputStream outpuStream = process.getOutputStream(); + final InputStream errorStream = process.getErrorStream(); + new Thread("jgit-local-errors") { + public void run() { + final byte[] tmp = new byte[512]; + try { + for (;;) { + final int n = errorStream.read(tmp); + if (n < 0) + break; + System.err.write(tmp, 0, n); + System.err.flush(); + } + } catch (IOException err) { + // Ignore errors reading errors. + } finally { + try { + errorStream.close(); + } catch (IOException err2) { + // Ignore errors closing the pipe. + } + } + for (;;) { + try { + process.waitFor(); + break; + } catch (InterruptedException ie) { + // Try again. + } + } + } + }.start(); return new LocalGitProtocolFetchClient(repository, remoteName, null, outpuStream, inputStream); } } -- 2.11.4.GIT