Merge "Add "--long" option to JGit describe"
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index 45e9fc1..58df895 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -88,7 +88,7 @@
* delta packed format yielding high compression of lots of object where some
* objects are similar.
*/
-public final class DfsPackFile implements AutoCloseable {
+public final class DfsPackFile {
/**
* File offset used to cache {@link #index} in {@link DfsBlockCache}.
* <p>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
index 223689b..eb22938 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
@@ -89,8 +89,7 @@
* delta packed format yielding high compression of lots of object where some
* objects are similar.
*/
-public class PackFile implements Iterable<PackIndex.MutableEntry>,
- AutoCloseable {
+public class PackFile implements Iterable<PackIndex.MutableEntry> {
/** Sorts PackFiles to be most recently created to least recently created. */
public static final Comparator<PackFile> SORT = new Comparator<PackFile>() {
public int compare(final PackFile a, final PackFile b) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java
index 3e77a10..0cc51d1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java
@@ -54,7 +54,7 @@
* An object database stores one or more Git objects, indexed by their unique
* {@link ObjectId}.
*/
-public abstract class ObjectDatabase implements AutoCloseable {
+public abstract class ObjectDatabase {
/** Initialize a new database instance for access. */
protected ObjectDatabase() {
// Protected to force extension.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
index b10f806..7fea880 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
@@ -57,7 +57,7 @@
* Every {@link Repository} has a single reference database, mapping names to
* the tips of the object graph contained by the {@link ObjectDatabase}.
*/
-public abstract class RefDatabase implements AutoCloseable {
+public abstract class RefDatabase {
/**
* Order of prefixes to search when using non-absolute references.
* <p>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
index c247847..222ca55 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
@@ -99,9 +99,7 @@ else if (repo.getDirectory() != null)
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
- String sentNonce = String.format(
- "%d-%20X", new Long(timestamp), rawHmac); //$NON-NLS-1$
- return sentNonce;
+ return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
}
@Override
@@ -146,4 +144,15 @@ else if (received.equals(sent))
return NonceStatus.SLOP;
}
}
+
+ private static final String HEX = "0123456789ABCDEF"; //$NON-NLS-1$
+
+ private static String toHex(byte[] bytes) {
+ StringBuilder builder = new StringBuilder(2 * bytes.length);
+ for (byte b : bytes) {
+ builder.append(HEX.charAt((b & 0xF0) >> 4));
+ builder.append(HEX.charAt(b & 0xF));
+ }
+ return builder.toString();
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
index 455b465..8ee4c17 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
@@ -49,55 +49,33 @@
* @since 4.0
*/
public class PushCertificate {
-
- /** The tuple "name <email>" as presented in the push certificate */
+ /** The tuple "name <email>" as presented in the push certificate. */
String pusher;
- /** The remote URL the signed push goes to */
+ /** The remote URL the signed push goes to. */
String pushee;
- /** What we think about the returned signed nonce */
+ /** What we think about the returned signed nonce. */
NonceStatus nonceStatus;
- /**
- *
- *
- */
+ /** Verification result of the nonce returned during push. */
public enum NonceStatus {
- /**
- *
- */
+ /** Nonce was not expected, yet client sent one anyway. */
UNSOLICITED,
- /**
- *
- */
+ /** Nonce is invalid and did not match server's expectations. */
BAD,
- /**
- *
- */
+ /** Nonce is required, but was not sent by client. */
MISSING,
- /**
- *
- */
+ /** Received nonce is valid. */
OK,
- /**
- *
- */
+ /** Received nonce is valid and within the accepted slop window. */
SLOP
}
- /**
- *
- */
String commandList;
-
- /**
- *
- */
String signature;
/**
- *
* @return the signature, consisting of the lines received between the lines
* '----BEGIN GPG SIGNATURE-----\n' and the '----END GPG
* SIGNATURE-----\n'
@@ -115,22 +93,19 @@ public String getCommandList() {
}
/**
- * @return the pushedCertPusher
+ * @return the tuple "name <email>" as presented by the client in the
+ * push certificate.
*/
public String getPusher() {
return pusher;
}
- /**
- * @return the pushedCertPushee
- */
+ /** @return URL of the repository the push was originally sent to. */
public String getPushee() {
return pushee;
}
- /**
- * @return the pushCertNonceStatus
- */
+ /** @return verification status of the nonce embedded in the certificate. */
public NonceStatus getNonceStatus() {
return nonceStatus;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java
index d111a22..4bb3d6b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java
@@ -130,18 +130,20 @@ private String parseNextLine(PacketLineIn pckIn, String startingWith)
/**
* Receive a list of commands from the input encapsulated in a push
- * certificate. This method doesn't deal with the first line "push-cert \NUL
- * <capabilities>", but assumes the first line including the capabilities
- * has already been dealt with.
+ * certificate. This method doesn't parse the first line "push-cert \NUL
+ * <capabilities>", but assumes the first line including the
+ * capabilities has already been handled by the caller.
*
* @param pckIn
* where we take the push certificate header from.
* @param stateless
- * If this server is run as a stateless server, such that it
- * cannot store the sent push certificate and needs to validate
- * what the client sends back.
- *
+ * affects nonce verification. When {@code stateless = true} the
+ * {@code NonceGenerator} will allow for some time skew caused by
+ * clients disconnected and reconnecting in the stateless smart
+ * HTTP protocol.
* @throws IOException
+ * if the certificate from the client is badly malformed or the
+ * client disconnects before sending the entire certificate.
*/
public void receiveHeader(PacketLineIn pckIn, boolean stateless)
throws IOException {
@@ -156,7 +158,7 @@ public void receiveHeader(PacketLineIn pckIn, boolean stateless)
pushee = parseNextLine(pckIn, PUSHEE);
receivedNonce = parseNextLine(pckIn, NONCE);
// an empty line
- if (pckIn.readString() != "") { //$NON-NLS-1$
+ if (!pckIn.readString().isEmpty()) {
throw new IOException(MessageFormat.format(
JGitText.get().errorInvalidPushCert,
"expected empty line after header")); //$NON-NLS-1$