and
+ * other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v1.0 which accompanies this
+ * distribution, is reproduced below, and is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.eclipse.jgit.api.errors;
+
+/**
+ * Exception thrown when the server rejected a too large pack
+ *
+ * @since 4.0
+ */
+public class TooLargePackException extends TransportException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param msg
+ * message describing the transport failure.
+ */
+ public TooLargePackException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * @param msg
+ * message describing the transport exception.
+ * @param cause
+ * why the transport failed.
+ */
+ public TooLargePackException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java
index 6216fdedb..9810a6ab2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java
@@ -114,6 +114,7 @@ import org.eclipse.jgit.util.LongList;
public class MyersDiff {
/** Singleton instance of MyersDiff. */
public static final DiffAlgorithm INSTANCE = new LowLevelDiffAlgorithm() {
+ @SuppressWarnings("unused")
@Override
public void diffNonCommon(EditList edits,
HashedSequenceComparator cmp, HashedSequence a,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
index f376b8e36..1c40d7fcb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
@@ -63,10 +63,13 @@ import org.eclipse.jgit.lib.ObjectStream;
* will not exceed 1 MiB per instance. The index starts out at a smaller size
* (closer to 2 KiB), but may grow as more distinct blocks within the scanned
* file are discovered.
+ *
+ * @since 4.0
*/
-class SimilarityIndex {
+public class SimilarityIndex {
/** A special {@link TableFullException} used in place of OutOfMemoryError. */
- private static final TableFullException TABLE_FULL_OUT_OF_MEMORY = new TableFullException();
+ public static final TableFullException
+ TABLE_FULL_OUT_OF_MEMORY = new TableFullException();
/**
* Shift to apply before storing a key.
@@ -105,6 +108,26 @@ class SimilarityIndex {
/** {@code idHash.length == 1 << idHashBits}. */
private int idHashBits;
+ /**
+ * Create a new similarity index for the given object
+ *
+ * @param obj
+ * the object to hash
+ * @return similarity index for this object
+ * @throws IOException
+ * file contents cannot be read from the repository.
+ * @throws TableFullException
+ * object hashing overflowed the storage capacity of the
+ * SimilarityIndex.
+ */
+ public static SimilarityIndex create(ObjectLoader obj) throws IOException,
+ TableFullException {
+ SimilarityIndex idx = new SimilarityIndex();
+ idx.hash(obj);
+ idx.sort();
+ return idx;
+ }
+
SimilarityIndex() {
idHashBits = 8;
idHash = new long[1 << idHashBits];
@@ -212,7 +235,27 @@ class SimilarityIndex {
Arrays.sort(idHash);
}
- int score(SimilarityIndex dst, int maxScore) {
+ /**
+ * Compute the similarity score between this index and another.
+ *
+ * A region of a file is defined as a line in a text file or a fixed-size
+ * block in a binary file. To prepare an index, each region in the file is
+ * hashed; the values and counts of hashes are retained in a sorted table.
+ * Define the similarity fraction F as the the count of matching regions
+ * between the two files divided between the maximum count of regions in
+ * either file. The similarity score is F multiplied by the maxScore
+ * constant, yielding a range [0, maxScore]. It is defined as maxScore for
+ * the degenerate case of two empty files.
+ *
+ * The similarity score is symmetrical; i.e. a.score(b) == b.score(a).
+ *
+ * @param dst
+ * the other index
+ * @param maxScore
+ * the score representing a 100% match
+ * @return the similarity score
+ */
+ public int score(SimilarityIndex dst, int maxScore) {
long max = Math.max(hashedCnt, dst.hashedCnt);
if (max == 0)
return maxScore;
@@ -381,7 +424,8 @@ class SimilarityIndex {
return v & MAX_COUNT;
}
- static class TableFullException extends Exception {
+ /** Thrown by {@code create()} when file is too large. */
+ public static class TableFullException extends Exception {
private static final long serialVersionUID = 1L;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
index f316ea99a..00252547d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
@@ -1192,6 +1192,7 @@ public class DirCacheCheckout {
entry.setLastModified(f.lastModified());
}
+ @SuppressWarnings("deprecation")
private static void checkValidPath(CanonicalTreeParser t)
throws InvalidPathException {
ObjectChecker chk = new ObjectChecker()
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargePackException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargePackException.java
index 5cf0f802c..d54798541 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargePackException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargePackException.java
@@ -43,17 +43,17 @@
package org.eclipse.jgit.errors;
-import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.transport.URIish;
/**
* Thrown when a pack exceeds a given size limit
*
* @since 3.3
*/
-public class TooLargePackException extends IOException {
+public class TooLargePackException extends TransportException {
private static final long serialVersionUID = 1L;
/**
@@ -66,4 +66,17 @@ public class TooLargePackException extends IOException {
super(MessageFormat.format(JGitText.get().receivePackTooLarge,
Long.valueOf(packSizeLimit)));
}
+
+ /**
+ * Construct a too large pack exception.
+ *
+ * @param uri
+ * URI used for transport
+ * @param s
+ * message
+ * @since 4.0
+ */
+ public TooLargePackException(URIish uri, String s) {
+ super(uri.setPass(null) + ": " + s); //$NON-NLS-1$
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
index ec9fdfa4e..fa27948a6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
@@ -205,7 +205,7 @@ public class ManifestParser extends DefaultHandler {
throw new SAXException(RepoText.get().invalidManifest);
currentProject.addCopyFile(new CopyFile(
rootRepo,
- currentProject.path,
+ currentProject.getPath(),
attributes.getValue("src"), //$NON-NLS-1$
attributes.getValue("dest"))); //$NON-NLS-1$
} else if ("include".equals(qName)) { //$NON-NLS-1$
@@ -266,7 +266,7 @@ public class ManifestParser extends DefaultHandler {
throw new SAXException(e);
}
for (RepoProject proj : projects) {
- String remote = proj.remote;
+ String remote = proj.getRemote();
if (remote == null) {
if (defaultRemote == null) {
if (filename != null)
@@ -286,7 +286,7 @@ public class ManifestParser extends DefaultHandler {
remoteUrl = remoteUrl + "/"; //$NON-NLS-1$
remoteUrls.put(remote, remoteUrl);
}
- proj.setUrl(remoteUrl + proj.name)
+ proj.setUrl(remoteUrl + proj.getName())
.setDefaultRevision(defaultRevision);
}
@@ -339,7 +339,7 @@ public class ManifestParser extends DefaultHandler {
boolean inGroups(RepoProject proj) {
for (String group : minusGroups) {
- if (proj.groups.contains(group)) {
+ if (proj.inGroup(group)) {
// minus groups have highest priority.
return false;
}
@@ -349,7 +349,7 @@ public class ManifestParser extends DefaultHandler {
return true;
}
for (String group : plusGroups) {
- if (proj.groups.contains(group))
+ if (proj.inGroup(group))
return true;
}
return false;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
index d258250fe..b39dd8a1f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -379,10 +379,10 @@ public class RepoCommand extends GitCommand {
try {
parser.read(inputStream);
for (RepoProject proj : parser.getFilteredProjects()) {
- addSubmodule(proj.url,
- proj.path,
+ addSubmodule(proj.getUrl(),
+ proj.getPath(),
proj.getRevision(),
- proj.copyfiles);
+ proj.getCopyFiles());
}
} catch (GitAPIException | IOException e) {
throw new ManifestErrorException(e);
@@ -403,17 +403,17 @@ public class RepoCommand extends GitCommand {
try (RevWalk rw = new RevWalk(repo)) {
Config cfg = new Config();
for (RepoProject proj : bareProjects) {
- String name = proj.path;
- String nameUri = proj.name;
+ String name = proj.getPath();
+ String nameUri = proj.getName();
cfg.setString("submodule", name, "path", name); //$NON-NLS-1$ //$NON-NLS-2$
cfg.setString("submodule", name, "url", nameUri); //$NON-NLS-1$ //$NON-NLS-2$
// create gitlink
DirCacheEntry dcEntry = new DirCacheEntry(name);
ObjectId objectId;
- if (ObjectId.isId(proj.revision))
- objectId = ObjectId.fromString(proj.revision);
+ if (ObjectId.isId(proj.getRevision()))
+ objectId = ObjectId.fromString(proj.getRevision());
else {
- objectId = callback.sha1(nameUri, proj.revision);
+ objectId = callback.sha1(nameUri, proj.getRevision());
}
if (objectId == null)
throw new RemoteUnavailableException(nameUri);
@@ -421,9 +421,9 @@ public class RepoCommand extends GitCommand {
dcEntry.setFileMode(FileMode.GITLINK);
builder.add(dcEntry);
- for (CopyFile copyfile : proj.copyfiles) {
+ for (CopyFile copyfile : proj.getCopyFiles()) {
byte[] src = callback.readFile(
- nameUri, proj.revision, copyfile.src);
+ nameUri, proj.getRevision(), copyfile.src);
objectId = inserter.insert(Constants.OBJ_BLOB, src);
dcEntry = new DirCacheEntry(copyfile.dest);
dcEntry.setObjectId(objectId);
@@ -495,7 +495,7 @@ public class RepoCommand extends GitCommand {
List copyfiles) throws GitAPIException, IOException {
if (repo.isBare()) {
RepoProject proj = new RepoProject(url, name, revision, null, null);
- proj.copyfiles.addAll(copyfiles);
+ proj.addCopyFiles(copyfiles);
bareProjects.add(proj);
} else {
SubmoduleAddCommand add = git
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
index dfd4f1bba..1fff1c353 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
@@ -49,6 +49,8 @@ import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -62,14 +64,14 @@ import org.eclipse.jgit.lib.Repository;
* @since 4.0
*/
public class RepoProject implements Comparable {
- final String name;
- final String path;
- final String revision;
- final String remote;
- final Set groups;
- final List copyfiles;
- String url;
- String defaultRevision;
+ private final String name;
+ private final String path;
+ private final String revision;
+ private final String remote;
+ private final Set groups;
+ private final List copyfiles;
+ private String url;
+ private String defaultRevision;
/**
* The representation of a copy file configuration.
@@ -82,10 +84,13 @@ public class RepoProject implements Comparable {
/**
* @param repo
+ * the super project.
* @param path
* the path of the project containing this copyfile config.
* @param src
+ * the source path relative to the sub repo.
* @param dest
+ * the destination path relative to the super project.
*/
public CopyFile(Repository repo, String path, String src, String dest) {
this.repo = repo;
@@ -108,7 +113,8 @@ public class RepoProject implements Comparable {
FileOutputStream output = new FileOutputStream(destFile);
try {
FileChannel channel = input.getChannel();
- output.getChannel().transferFrom(channel, 0, channel.size());
+ output.getChannel().transferFrom(
+ channel, 0, channel.size());
} finally {
output.close();
}
@@ -120,10 +126,15 @@ public class RepoProject implements Comparable {
/**
* @param name
+ * the relative path to the {@code remote}
* @param path
+ * the relative path to the super project
* @param revision
+ * a SHA-1 or branch name or tag name
* @param remote
+ * name of the remote definition
* @param groups
+ * comma separated group list
*/
public RepoProject(String name, String path, String revision,
String remote, String groups) {
@@ -162,15 +173,70 @@ public class RepoProject implements Comparable {
return this;
}
+ /**
+ * Get the name (relative path to the {@code remote}) of this sub repo.
+ *
+ * @return {@code name}
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the path (relative path to the super project) of this sub repo.
+ *
+ * @return {@code path}
+ */
+ public String getPath() {
+ return path;
+ }
+
/**
* Get the revision of the sub repo.
*
- * @return revision if set, or default revision.
+ * @return {@code revision} if set, or {@code defaultRevision}.
*/
public String getRevision() {
return revision == null ? defaultRevision : revision;
}
+ /**
+ * Getter for the copyfile configurations.
+ *
+ * @return Immutable copy of {@code copyfiles}
+ */
+ public List getCopyFiles() {
+ return Collections.unmodifiableList(copyfiles);
+ }
+
+ /**
+ * Get the url of the sub repo.
+ *
+ * @return {@code url}
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * Get the name of the remote definition of the sub repo.
+ *
+ * @return {@remote}
+ */
+ public String getRemote() {
+ return remote;
+ }
+
+ /**
+ * Test whether this sub repo belongs to a specified group.
+ *
+ * @param group
+ * @return true if {@code group} is present.
+ */
+ public boolean inGroup(String group) {
+ return groups.contains(group);
+ }
+
/**
* Add a copy file configuration.
*
@@ -180,7 +246,16 @@ public class RepoProject implements Comparable {
copyfiles.add(copyfile);
}
- String getPathWithSlash() {
+ /**
+ * Add a bunch of copyfile configurations.
+ *
+ * @param copyfiles
+ */
+ public void addCopyFiles(Collection copyfiles) {
+ this.copyfiles.addAll(copyfiles);
+ }
+
+ private String getPathWithSlash() {
if (path.endsWith("/")) //$NON-NLS-1$
return path;
else
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index b53c7c95f..9f6efef57 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -316,6 +316,7 @@ public class JGitText extends TranslationBundle {
/***/ public String exceptionCaughtDuringExecutionOfRevertCommand;
/***/ public String exceptionCaughtDuringExecutionOfRmCommand;
/***/ public String exceptionCaughtDuringExecutionOfTagCommand;
+ /***/ public String exceptionCaughtDuringExcecutionOfCommand;
/***/ public String exceptionHookExecutionInterrupted;
/***/ public String exceptionOccurredDuringAddingOfOptionToALogCommand;
/***/ public String exceptionOccurredDuringReadingOfGIT_DIR;
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 e03488b3c..75b0646ed 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
@@ -533,6 +533,7 @@ public final class DfsPackFile {
return ByteBuffer.wrap(copyBuf, 0, bs);
}
+ @SuppressWarnings("null")
void copyAsIs(PackOutputStream out, DfsObjectToPack src,
boolean validate, DfsReader ctx) throws IOException,
StoredObjectRepresentationNotAvailableException {
@@ -836,6 +837,7 @@ public final class DfsPackFile {
return buf.position();
}
+ @SuppressWarnings("null")
ObjectLoader load(DfsReader ctx, long pos)
throws IOException {
try {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
index a186b8147..1c076ee09 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
@@ -366,11 +366,10 @@ public class ObjectDirectoryPackParser extends PackParser {
@Override
protected void onEndThinPack() throws IOException {
- final byte[] tailHash = this.tailDigest.digest();
final byte[] buf = buffer();
final MessageDigest origDigest = Constants.newMessageDigest();
- final MessageDigest tailDigest = Constants.newMessageDigest();
+ final MessageDigest tailDigest2 = Constants.newMessageDigest();
final MessageDigest packDigest = Constants.newMessageDigest();
long origRemaining = origEnd;
@@ -393,15 +392,15 @@ public class ObjectDirectoryPackParser extends PackParser {
origDigest.update(buf, 0, origCnt);
origRemaining -= origCnt;
if (origRemaining == 0)
- tailDigest.update(buf, origCnt, n - origCnt);
+ tailDigest2.update(buf, origCnt, n - origCnt);
} else
- tailDigest.update(buf, 0, n);
+ tailDigest2.update(buf, 0, n);
packDigest.update(buf, 0, n);
}
- if (!Arrays.equals(origDigest.digest(), origHash)
- || !Arrays.equals(tailDigest.digest(), tailHash))
+ if (!Arrays.equals(origDigest.digest(), origHash) || !Arrays
+ .equals(tailDigest2.digest(), this.tailDigest.digest()))
throw new IOException(
JGitText.get().packCorruptedWhileWritingToFilesystem);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
index 9cb834957..154809bad 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
@@ -80,6 +80,6 @@ class PackInputStream extends InputStream {
@Override
public void close() {
- wc.release();
+ wc.close();
}
}
\ No newline at end of file
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
index cb95a7656..e4cc69796 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
@@ -91,11 +91,8 @@ public class UnpackedObject {
*/
public static ObjectLoader parse(byte[] raw, AnyObjectId id)
throws IOException {
- WindowCursor wc = new WindowCursor(null);
- try {
+ try (WindowCursor wc = new WindowCursor(null)) {
return open(new ByteArrayInputStream(raw), null, id, wc);
- } finally {
- wc.release();
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
index 3e6cb5835..a555e10d4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
@@ -330,7 +330,8 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
}
/** Release the current window cursor. */
- public void release() {
+ @Override
+ public void close() {
window = null;
baseCache = null;
try {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 8fac90727..adc6bf11a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -1591,6 +1591,7 @@ public class PackWriter implements AutoCloseable {
findObjectsToPackUsingBitmaps(bitmapWalker, want, have);
endPhase(countingMonitor);
stats.timeCounting = System.currentTimeMillis() - countingStart;
+ stats.bitmapIndexMisses = bitmapWalker.getCountOfBitmapIndexMisses();
return;
}
}
@@ -2084,6 +2085,8 @@ public class PackWriter implements AutoCloseable {
long totalObjects;
+ long bitmapIndexMisses;
+
long totalDeltas;
long reusedObjects;
@@ -2165,6 +2168,16 @@ public class PackWriter implements AutoCloseable {
return totalObjects;
}
+ /**
+ * @return the count of objects that needed to be discovered through an
+ * object walk because they were not found in bitmap indices.
+ *
+ * @since 4.0
+ */
+ public long getBitmapIndexMisses() {
+ return bitmapIndexMisses;
+ }
+
/**
* @return total number of deltas output. This may be lower than the
* actual number of deltas if a cached pack was reused.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java
index 63a91cd82..debb2f2ab 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java
@@ -71,6 +71,8 @@ final class PackWriterBitmapWalker {
private final ProgressMonitor pm;
+ private long countOfBitmapIndexMisses;
+
PackWriterBitmapWalker(
ObjectWalk walker, BitmapIndex bitmapIndex, ProgressMonitor pm) {
this.walker = walker;
@@ -78,6 +80,10 @@ final class PackWriterBitmapWalker {
this.pm = (pm == null) ? NullProgressMonitor.INSTANCE : pm;
}
+ long getCountOfBitmapIndexMisses() {
+ return countOfBitmapIndexMisses;
+ }
+
BitmapBuilder findObjects(Set extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissingStart)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
@@ -104,7 +110,8 @@ final class PackWriterBitmapWalker {
}
if (marked) {
- walker.setRevFilter(newRevFilter(seen, bitmapResult));
+ BitmapRevFilter filter = newRevFilter(seen, bitmapResult);
+ walker.setRevFilter(filter);
while (walker.next() != null) {
// Iterate through all of the commits. The BitmapRevFilter does
@@ -117,6 +124,7 @@ final class PackWriterBitmapWalker {
bitmapResult.add(ro, ro.getType());
pm.update(1);
}
+ countOfBitmapIndexMisses += filter.getCountOfLoadedCommits();
}
return bitmapResult;
@@ -126,7 +134,7 @@ final class PackWriterBitmapWalker {
walker.reset();
}
- static RevFilter newRevFilter(
+ static BitmapRevFilter newRevFilter(
final BitmapBuilder seen, final BitmapBuilder bitmapResult) {
if (seen != null) {
return new BitmapRevFilter() {
@@ -146,12 +154,16 @@ final class PackWriterBitmapWalker {
}
static abstract class BitmapRevFilter extends RevFilter {
+ private long countOfLoadedCommits;
+
protected abstract boolean load(RevCommit cmit);
@Override
public final boolean include(RevWalk walker, RevCommit cmit) {
- if (load(cmit))
+ if (load(cmit)) {
+ countOfLoadedCommits++;
return true;
+ }
for (RevCommit p : cmit.getParents())
p.add(RevFlag.SEEN);
return false;
@@ -166,5 +178,9 @@ final class PackWriterBitmapWalker {
public final boolean requiresCommitBody() {
return false;
}
+
+ long getCountOfLoadedCommits() {
+ return countOfLoadedCommits;
+ }
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
index eecbc224b..45dd7ee1a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
@@ -565,14 +565,16 @@ public class BaseRepositoryBuilder ref = cacheMap.get(location);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java
index 977f95341..a9a8231ee 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java
@@ -102,7 +102,7 @@ public class MergeFormatter {
* metadata
* @throws IOException
*/
- public void formatMerge(OutputStream out, MergeResult res, String baseName,
+ public void formatMerge(OutputStream out, MergeResult res, String baseName,
String oursName, String theirsName, String charsetName) throws IOException {
List names = new ArrayList(3);
names.add(baseName);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java
index 69abd0d97..4205fc4e8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java
@@ -221,6 +221,7 @@ public class WindowCacheConfig {
*
* @since 3.0
*/
+ @SuppressWarnings("deprecation")
public void install() {
WindowCache.reconfigure(this);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java
index 1e5b8e8ad..24fb3be64 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java
@@ -55,6 +55,7 @@ import java.util.Set;
import org.eclipse.jgit.errors.NoRemoteRepositoryException;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.PackProtocolException;
+import org.eclipse.jgit.errors.TooLargePackException;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.pack.PackWriter;
@@ -314,6 +315,9 @@ public abstract class BasePackPushConnection extends BasePackConnection implemen
if (!unpackLine.startsWith("unpack ")) //$NON-NLS-1$
throw new PackProtocolException(uri, MessageFormat.format(JGitText.get().unexpectedReportLine, unpackLine));
final String unpackStatus = unpackLine.substring("unpack ".length()); //$NON-NLS-1$
+ if (unpackStatus.startsWith("error Pack exceeds the limit of")) //$NON-NLS-1$
+ throw new TooLargePackException(uri,
+ unpackStatus.substring("error ".length())); //$NON-NLS-1$
if (!unpackStatus.equals("ok")) //$NON-NLS-1$
throw new TransportException(uri, MessageFormat.format(
JGitText.get().errorOccurredDuringUnpackingOnTheRemoteEnd, unpackStatus));
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
index eb770125c..9112ecbe3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -1583,7 +1583,9 @@ public abstract class BaseReceivePack {
pckIn = null;
pckOut = null;
refs = null;
- enabledCapabilities = null;
+ // Keep the capabilities. If responses are sent after this release
+ // we need to remember at least whether sideband communication has to be
+ // used
commands = null;
if (timer != null) {
try {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
index e5eb82241..44b8778ee 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -240,10 +240,16 @@ public class ReceivePack extends BaseReceivePack {
});
}
- postReceive.onPostReceive(this, filterCommands(Result.OK));
-
- if (unpackError != null)
+ if (unpackError != null) {
+ // we already know which exception to throw. Ignore
+ // potential additional exceptions raised in postReceiveHooks
+ try {
+ postReceive.onPostReceive(this, filterCommands(Result.OK));
+ } catch (Throwable e) {
+ }
throw new UnpackException(unpackError);
+ }
+ postReceive.onPostReceive(this, filterCommands(Result.OK));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java
index c47645cd7..fa073ae2a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java
@@ -227,6 +227,7 @@ public class TransportSftp extends SshTransport implements WalkTransport {
Collection getPackNames() throws IOException {
final List packs = new ArrayList();
try {
+ @SuppressWarnings("unchecked")
final Collection list = ftp.ls("pack"); //$NON-NLS-1$
final HashMap files;
final HashMap mtimes;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index c60590dda..753277dd3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -810,9 +810,9 @@ public class UploadPack {
adv.advertiseCapability(OPTION_ALLOW_TIP_SHA1_IN_WANT);
adv.advertiseCapability(OPTION_AGENT, UserAgent.get());
adv.setDerefTags(true);
- Map refs = getAdvertisedOrDefaultRefs();
- findSymrefs(adv, refs);
- advertised = adv.send(refs);
+ Map advertisedOrDefaultRefs = getAdvertisedOrDefaultRefs();
+ findSymrefs(adv, advertisedOrDefaultRefs);
+ advertised = adv.send(advertisedOrDefaultRefs);
if (adv.isEmpty())
adv.advertiseId(ObjectId.zeroId(), "capabilities^{}"); //$NON-NLS-1$
adv.end();
@@ -1467,7 +1467,7 @@ public class UploadPack {
pckOut.end();
}
- private void findSymrefs(
+ private static void findSymrefs(
final RefAdvertiser adv, final Map refs) {
Ref head = refs.get(Constants.HEAD);
if (head != null && head.isSymbolic()) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
index 3ef3d9791..42725bc76 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
@@ -224,7 +224,8 @@ public class IndexDiffFilter extends TreeFilter {
// Only one chance left to detect a diff: between index and working
// tree. Make use of the WorkingTreeIterator#isModified() method to
// avoid computing SHA1 on filesystem content if not really needed.
- return wi.isModified(di.getDirCacheEntry(), true, tw.getObjectReader());
+ return wi.isModified(di == null ? null : di.getDirCacheEntry(), true,
+ tw.getObjectReader());
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index fa0292e79..12dfe96b0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -440,40 +440,11 @@ public abstract class FS {
if (env != null) {
pb.environment().putAll(env);
}
- final Process p = pb.start();
- final BufferedReader lineRead = new BufferedReader(
+ Process p = pb.start();
+ BufferedReader lineRead = new BufferedReader(
new InputStreamReader(p.getInputStream(), encoding));
p.getOutputStream().close();
- final AtomicBoolean gooblerFail = new AtomicBoolean(false);
- Thread gobbler = new Thread() {
- public void run() {
- InputStream is = p.getErrorStream();
- try {
- int ch;
- if (debug)
- while ((ch = is.read()) != -1)
- System.err.print((char) ch);
- else
- while (is.read() != -1) {
- // ignore
- }
- } catch (IOException e) {
- // Just print on stderr for debugging
- if (debug)
- e.printStackTrace(System.err);
- gooblerFail.set(true);
- }
- try {
- is.close();
- } catch (IOException e) {
- // Just print on stderr for debugging
- if (debug) {
- LOG.debug("Caught exception in gobbler thread", e); //$NON-NLS-1$
- }
- gooblerFail.set(true);
- }
- }
- };
+ GobblerThread gobbler = new GobblerThread(p, command, dir);
gobbler.start();
String r = null;
try {
@@ -498,7 +469,7 @@ public abstract class FS {
int rc = p.waitFor();
gobbler.join();
if (rc == 0 && r != null && r.length() > 0
- && !gooblerFail.get())
+ && !gobbler.fail.get())
return r;
if (debug) {
LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$
@@ -517,6 +488,59 @@ public abstract class FS {
return null;
}
+ private static class GobblerThread extends Thread {
+ private final Process p;
+ private final String desc;
+ private final String dir;
+ private final boolean debug = LOG.isDebugEnabled();
+ private final AtomicBoolean fail = new AtomicBoolean();
+
+ private GobblerThread(Process p, String[] command, File dir) {
+ this.p = p;
+ if (debug) {
+ this.desc = Arrays.asList(command).toString();
+ this.dir = dir.toString();
+ } else {
+ this.desc = null;
+ this.dir = null;
+ }
+ }
+
+ public void run() {
+ InputStream is = p.getErrorStream();
+ try {
+ int ch;
+ if (debug) {
+ while ((ch = is.read()) != -1) {
+ System.err.print((char) ch);
+ }
+ } else {
+ while (is.read() != -1) {
+ // ignore
+ }
+ }
+ } catch (IOException e) {
+ logError(e);
+ fail.set(true);
+ }
+ try {
+ is.close();
+ } catch (IOException e) {
+ logError(e);
+ fail.set(true);
+ }
+ }
+
+ private void logError(Throwable t) {
+ if (!debug) {
+ return;
+ }
+ String msg = MessageFormat.format(
+ JGitText.get().exceptionCaughtDuringExcecutionOfCommand, desc, dir);
+ LOG.debug(msg, t);
+ }
+ }
+
/**
* @return the path to the Git executable or {@code null} if it cannot be
* determined.
diff --git a/pom.xml b/pom.xml
index ce4cc67a5..2ed818b71 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,15 +56,25 @@
JGit - Parent
${jgit-url}
+
+ Eclipse JGit Project
+ http://www.eclipse.org/jgit
+
+
Pure Java implementation of Git
- http://egit.eclipse.org/w/?p=jgit.git
- scm:git:git://egit.eclipse.org/jgit.git
+ http://git.eclipse.org/c/jgit/jgit.git/
+ scm:git:https://git.eclipse.org/r/jgit/jgit
+
+ hudson
+ https://hudson.eclipse.org/jgit/
+
+
Chris Aniszczyk
@@ -81,6 +91,9 @@
Gunnar Wagenknecht
+
+ Jonathan Nieder
+
Kevin Sawicki
@@ -93,6 +106,9 @@
Robin Rosenberg
+
+ Robin Stocker
+
Sasa Zivkov
@@ -176,21 +192,22 @@
yyyyMMddHHmm
${project.build.directory}/META-INF/MANIFEST.MF
- 3.6.0.201412230720-r
- 0.1.50
+ 3.7.0.201502260915-r
+ 0.1.51
0.7.9
4.11
1C
2.0.15
1.6
4.3.1
- 2.5
+ 3.1.0
9.2.10.v20150310
2.6.1
4.1.3
1.7.2
1.2.15
2.10.1
+ 0.22.0
jacoco
@@ -355,12 +372,12 @@
org.eclipse.tycho.extras
tycho-pack200a-plugin
- 0.22.0
+ ${tycho-extras-version}
org.eclipse.tycho.extras
tycho-pack200b-plugin
- 0.22.0
+ ${tycho-extras-version}
org.jacoco
@@ -379,6 +396,21 @@
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+ 2.18.1
+
+
+ org.apache.maven.plugins
+ maven-jxr-plugin
+ 2.5
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+ 2.8
+
@@ -478,6 +510,10 @@
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+