aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-02-10 11:49:27 -0800
committerShawn O. Pearce <spearce@spearce.org>2010-03-12 16:08:13 -0800
commit673b3984bdc540da99e1c390cf31f455896a1cda (patch)
tree9763b508c56a141130be2de1e46eca4659f77e94 /org.eclipse.jgit.pgm/src
parentd33f939e8eb47795c1ec8e89a605303770e95f34 (diff)
downloadjgit-673b3984bdc540da99e1c390cf31f455896a1cda.tar.gz
jgit-673b3984bdc540da99e1c390cf31f455896a1cda.zip
Capture non-progress side band #2 messages and put in result
Any messages received on side band #2 that aren't scraped as a progress message into our ProgressMonitor are now forwarded to a buffer which is later included into the OperationResult object. Application callers can use this buffer to present the additional messages from the remote peer after the push or fetch operation has concluded. The smart push connections using the native send-pack/receive-pack protocol now request side-band-64k capability if it is available and forward any messages received through that channel onto this message buffer. This makes hook messages available over smart HTTP, or even over SSH. The SSH transport was modified to redirect the remote command's stderr stream into the message buffer, interleaved with any data received over side band #2. Due to buffering between these two different channels in the SSH channel mux itself the order of any writes between the two cannot be ensured, but it tries to stay close. The local fork transport was also modified to redirect the local receive-pack's stderr into the message buffer, rather than going to the invoking JVM's System.err. This gives applications a chance to log the local error messages, rather than needing to redirect their JVM's stderr before startup. To keep things simple, the application has to wait for the entire operation to complete before it can see the messages. This may be a downside if the user is trying to debug a remote hook that is blocking indefinitely, the user would need to abort the connection before they can inspect the message buffer in any sort of UI built on top of JGit. Change-Id: Ibc215f4569e63071da5b7e5c6674ce924ae39e11 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java30
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java1
2 files changed, 30 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
index f5e3c504c2..1e03567500 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Charles O'Farrell <charleso@charleso.org>
- * Copyright (C) 2008-2009, Google Inc.
+ * Copyright (C) 2008-2010, Google Inc.
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
@@ -79,6 +79,34 @@ abstract class AbstractFetchCommand extends TextBuiltin {
out.format(" %c %-17s %-10s -> %s", type, longType, src, dst);
out.println();
}
+
+ showRemoteMessages(r.getMessages());
+ }
+
+ static void showRemoteMessages(String pkt) {
+ while (0 < pkt.length()) {
+ final int lf = pkt.indexOf('\n');
+ final int cr = pkt.indexOf('\r');
+ final int s;
+ if (0 <= lf && 0 <= cr)
+ s = Math.min(lf, cr);
+ else if (0 <= lf)
+ s = lf;
+ else if (0 <= cr)
+ s = cr;
+ else {
+ System.err.println("remote: " + pkt);
+ break;
+ }
+
+ if (pkt.charAt(s) == '\r')
+ System.err.print("remote: " + pkt.substring(0, s) + "\r");
+ else
+ System.err.println("remote: " + pkt.substring(0, s));
+
+ pkt = pkt.substring(s + 1);
+ }
+ System.err.flush();
}
private String longTypeOf(final TrackingRefUpdate u) {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
index 6248ec2991..2c02545639 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
@@ -162,6 +162,7 @@ class Push extends TextBuiltin {
printRefUpdateResult(uri, result, rru);
}
+ AbstractFetchCommand.showRemoteMessages(result.getMessages());
if (everythingUpToDate)
out.println("Everything up-to-date");
}