aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java26
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineOut.java10
2 files changed, 31 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java
index 8d291b8517..e142babd68 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java
@@ -55,6 +55,8 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.RawParseUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Read Git style pkt-line formatting from an input stream.
@@ -67,6 +69,8 @@ import org.eclipse.jgit.util.RawParseUtils;
* against the underlying InputStream.
*/
public class PacketLineIn {
+ private static final Logger log = LoggerFactory.getLogger(PacketLineIn.class);
+
/** Magic return from {@link #readString()} when a flush packet is found. */
public static final String END = new StringBuilder(0).toString(); /* must not string pool */
@@ -136,12 +140,16 @@ public class PacketLineIn {
*/
public String readString() throws IOException {
int len = readLength();
- if (len == 0)
+ if (len == 0) {
+ log.debug("git< 0000"); //$NON-NLS-1$
return END;
+ }
len -= 4; // length header (4 bytes)
- if (len == 0)
+ if (len == 0) {
+ log.debug("git< "); //$NON-NLS-1$
return ""; //$NON-NLS-1$
+ }
byte[] raw;
if (len <= lineBuffer.length)
@@ -152,7 +160,10 @@ public class PacketLineIn {
IO.readFully(in, raw, 0, len);
if (raw[len - 1] == '\n')
len--;
- return RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+
+ String s = RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+ log.debug("git< " + s); //$NON-NLS-1$
+ return s;
}
/**
@@ -167,8 +178,10 @@ public class PacketLineIn {
*/
public String readStringRaw() throws IOException {
int len = readLength();
- if (len == 0)
+ if (len == 0) {
+ log.debug("git< 0000"); //$NON-NLS-1$
return END;
+ }
len -= 4; // length header (4 bytes)
@@ -179,7 +192,10 @@ public class PacketLineIn {
raw = new byte[len];
IO.readFully(in, raw, 0, len);
- return RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+
+ String s = RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+ log.debug("git< " + s); //$NON-NLS-1$
+ return s;
}
void discardUntilEnd() throws IOException {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineOut.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineOut.java
index 2d4e9c717f..a6bd342851 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineOut.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineOut.java
@@ -49,6 +49,9 @@ import java.io.IOException;
import java.io.OutputStream;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.util.RawParseUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Write Git style pkt-line formatting to an output stream.
@@ -61,6 +64,8 @@ import org.eclipse.jgit.lib.Constants;
* against the underlying OutputStream.
*/
public class PacketLineOut {
+ private static final Logger log = LoggerFactory.getLogger(PacketLineOut.class);
+
private final OutputStream out;
private final byte[] lenbuffer;
@@ -135,6 +140,10 @@ public class PacketLineOut {
formatLength(len + 4);
out.write(lenbuffer, 0, 4);
out.write(buf, pos, len);
+ if (log.isDebugEnabled()) {
+ String s = RawParseUtils.decode(Constants.CHARSET, buf, pos, len);
+ log.debug("git> " + s); //$NON-NLS-1$
+ }
}
/**
@@ -153,6 +162,7 @@ public class PacketLineOut {
public void end() throws IOException {
formatLength(0);
out.write(lenbuffer, 0, 4);
+ log.debug("git> 0000"); //$NON-NLS-1$
if (flushOnEnd)
flush();
}