summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2014-09-26 15:45:46 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2014-09-26 15:45:46 +0200
commit9fd1325ecbdfaa41965782166e77d0dc8dd936ec (patch)
treecc5111673ffa444c1c24ed6bf593855908038a88
parent85b62b4c9ce57e4caa7b10cd770b022bfef24ea9 (diff)
parent848186da86d624d09cd1518378edff4ad9b7f14f (diff)
downloadjgit-9fd1325ecbdfaa41965782166e77d0dc8dd936ec.tar.gz
jgit-9fd1325ecbdfaa41965782166e77d0dc8dd936ec.zip
Merge branch 'stable-3.5'
* stable-3.5: Prepare 3.5.1-SNAPSHOT builds JGit v3.5.0.201409260305-r Fix PackWriterBitmapWalker handling non-existing uninteresting objects Enable maven site generation for jgit Generate javadocs as part of Maven site project reports Compare API changes with clirr against 3.4.1 [cli] Use chaining credentials provider to enable .netrc Add chaining credentials provider [Java 8] Configure doclint to accept missing descriptions Do not use .netrc implicitly if no CredentialsProvider was set Prepare post 3.5.0-rc1 builds JGit 3.5.0.201409071800-rc1 Fix the ls-remote command when there is no local repo Change-Id: Iaa4485cac6ff9c7917380e89e12e416e0f52a557 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java6
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java5
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java29
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java131
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java3
8 files changed, 192 insertions, 15 deletions
diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
index 91034fd2cc..a01fd86b4d 100644
--- a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
+++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
@@ -48,8 +48,10 @@ package org.eclipse.jgit.console;
import java.io.Console;
import org.eclipse.jgit.errors.UnsupportedCredentialItem;
+import org.eclipse.jgit.transport.ChainingCredentialsProvider;
import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.NetRCCredentialsProvider;
import org.eclipse.jgit.transport.URIish;
/** Interacts with the user during authentication by using the text console. */
@@ -60,7 +62,9 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
if (c.cons == null)
throw new NoClassDefFoundError(
ConsoleText.get().noSystemConsoleAvailable);
- CredentialsProvider.setDefault(c);
+ CredentialsProvider cp = new ChainingCredentialsProvider(
+ new NetRCCredentialsProvider(), c);
+ CredentialsProvider.setDefault(cp);
}
private final Console cons = System.console();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
index 1842b725e9..93fcd66c55 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
@@ -80,6 +80,11 @@ class LsRemote extends TextBuiltin {
}
}
+ @Override
+ protected boolean requiresRepository() {
+ return false;
+ }
+
private void show(final AnyObjectId id, final String name)
throws IOException {
outw.print(id.name());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
index aba48bc35f..873b2cda45 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
@@ -54,6 +54,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -225,6 +226,25 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
}
/**
+ * Try to pass non-existing object as uninteresting, with ignoring setting.
+ * Use a repo with bitmap indexes because then PackWriter will use
+ * PackWriterBitmapWalker which had problems with this situation.
+ *
+ * @throws IOException
+ * @throws ParseException
+ */
+ @Test
+ public void testIgnoreNonExistingObjectsWithBitmaps() throws IOException,
+ ParseException {
+ final ObjectId nonExisting = ObjectId
+ .fromString("0000000000000000000000000000000000000001");
+ new GC(db).gc();
+ createVerifyOpenPack(EMPTY_SET_OBJECT,
+ Collections.singleton(nonExisting), false, true, true);
+ // shouldn't throw anything
+ }
+
+ /**
* Create pack basing on only interesting objects, then precisely verify
* content. No delta reuse here.
*
@@ -604,8 +624,17 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
final Set<ObjectId> uninterestings, final boolean thin,
final boolean ignoreMissingUninteresting)
throws MissingObjectException, IOException {
+ createVerifyOpenPack(interestings, uninterestings, thin,
+ ignoreMissingUninteresting, false);
+ }
+
+ private void createVerifyOpenPack(final Set<ObjectId> interestings,
+ final Set<ObjectId> uninterestings, final boolean thin,
+ final boolean ignoreMissingUninteresting, boolean useBitmaps)
+ throws MissingObjectException, IOException {
NullProgressMonitor m = NullProgressMonitor.INSTANCE;
writer = new PackWriter(config, db.newObjectReader());
+ writer.setUseBitmaps(useBitmaps);
writer.setThin(thin);
writer.setIgnoreMissingUninteresting(ignoreMissingUninteresting);
writer.preparePack(m, interestings, uninterestings);
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 79dc11ead1..164934704c 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
@@ -1847,9 +1847,10 @@ public class PackWriter {
Set<? extends ObjectId> have)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
- BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null);
+ BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true);
bitmapWalker.reset();
- BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap);
+ BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap,
+ false);
BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);
if (useCachedPacks && reuseSupport != null
@@ -2049,7 +2050,7 @@ public class PackWriter {
walker = bitmapPreparer.newBitmapWalker();
BitmapBuilder bitmap = walker.findObjects(
- Collections.singleton(cmit), null);
+ Collections.singleton(cmit), null, false);
if (last != null && cmit.isReuseWalker() && !bitmap.contains(last))
throw new IllegalStateException(MessageFormat.format(
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 2e9ce1ddc1..63a91cd82d 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
@@ -78,7 +78,7 @@ final class PackWriterBitmapWalker {
this.pm = (pm == null) ? NullProgressMonitor.INSTANCE : pm;
}
- BitmapBuilder findObjects(Set<? extends ObjectId> start, BitmapBuilder seen)
+ BitmapBuilder findObjects(Set<? extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissingStart)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();
@@ -91,9 +91,15 @@ final class PackWriterBitmapWalker {
boolean marked = false;
for (ObjectId obj : start) {
- if (!bitmapResult.contains(obj)) {
- walker.markStart(walker.parseAny(obj));
- marked = true;
+ try {
+ if (!bitmapResult.contains(obj)) {
+ walker.markStart(walker.parseAny(obj));
+ marked = true;
+ }
+ } catch (MissingObjectException e) {
+ if (ignoreMissingStart)
+ continue;
+ throw e;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java
new file mode 100644
index 0000000000..3e0ee2f645
--- /dev/null
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2014, Matthias Sohn <matthias.sohn@sap.com>
+ * 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.transport;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jgit.errors.UnsupportedCredentialItem;
+
+/**
+ * A credentials provider chaining multiple credentials providers
+ *
+ * @since 3.5
+ */
+public class ChainingCredentialsProvider extends CredentialsProvider {
+
+ private List<CredentialsProvider> credentialProviders;
+
+ /**
+ * Create a new chaining credential provider. This provider tries to
+ * retrieve credentials from the chained credential providers in the order
+ * they are given here. If multiple providers support the requested items
+ * and have non-null credentials the first of them will be used.
+ *
+ * @param providers
+ * credential providers asked for credentials in the order given
+ * here
+ */
+ public ChainingCredentialsProvider(CredentialsProvider... providers) {
+ this.credentialProviders = new ArrayList<CredentialsProvider>(
+ Arrays.asList(providers));
+ for (CredentialsProvider p : providers)
+ credentialProviders.add(p);
+ }
+
+ /**
+ * @return {@code true} if any of the credential providers in the list is
+ * interactive, otherwise {@code false}
+ * @see org.eclipse.jgit.transport.CredentialsProvider#isInteractive()
+ */
+ @Override
+ public boolean isInteractive() {
+ for (CredentialsProvider p : credentialProviders)
+ if (p.isInteractive())
+ return true;
+ return false;
+ }
+
+ /**
+ * @return {@code true} if any of the credential providers in the list
+ * supports the requested items, otherwise {@code false}
+ * @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[])
+ */
+ @Override
+ public boolean supports(CredentialItem... items) {
+ for (CredentialsProvider p : credentialProviders)
+ if (p.supports(items))
+ return true;
+ return false;
+ }
+
+ /**
+ * Populates the credential items with the credentials provided by the first
+ * credential provider in the list which populates them with non-null values
+ *
+ * @return {@code true} if any of the credential providers in the list
+ * supports the requested items, otherwise {@code false}
+ * @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[])
+ */
+ @Override
+ public boolean get(URIish uri, CredentialItem... items)
+ throws UnsupportedCredentialItem {
+ for (CredentialsProvider p : credentialProviders) {
+ if (p.supports(items)) {
+ p.get(uri, items);
+ if (isAnyNull(items))
+ continue;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isAnyNull(CredentialItem... items) {
+ for (CredentialItem i : items)
+ if (i == null)
+ return true;
+ return false;
+ }
+}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
index 837bd58d82..3ad1db2d49 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
@@ -311,10 +311,14 @@ public abstract class Transport {
public static Transport open(final Repository local, final String remote,
final Operation op) throws NotSupportedException,
URISyntaxException, TransportException {
- final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote);
- if (doesNotExist(cfg))
- return open(local, new URIish(remote), null);
- return open(local, cfg, op);
+ if (local != null) {
+ final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote);
+ if (doesNotExist(cfg))
+ return open(local, new URIish(remote), null);
+ return open(local, cfg, op);
+ } else
+ return open(new URIish(remote));
+
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
index cc07b85474..82d1737b96 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -264,9 +264,6 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
}
http = local.getConfig().get(HTTP_KEY);
proxySelector = ProxySelector.getDefault();
-
- if (getCredentialsProvider() == null)
- setCredentialsProvider(new NetRCCredentialsProvider());
}
/**