Browse Source

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>
stable-3.6
Matthias Sohn 10 years ago
parent
commit
9fd1325ecb
  1. 6
      org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
  2. 5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
  3. 29
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
  4. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  5. 14
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java
  6. 131
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ChainingCredentialsProvider.java
  7. 12
      org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
  8. 3
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java

6
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 java.io.Console;
import org.eclipse.jgit.errors.UnsupportedCredentialItem; import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.transport.ChainingCredentialsProvider;
import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.NetRCCredentialsProvider;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
/** Interacts with the user during authentication by using the text console. */ /** Interacts with the user during authentication by using the text console. */
@ -60,7 +62,9 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
if (c.cons == null) if (c.cons == null)
throw new NoClassDefFoundError( throw new NoClassDefFoundError(
ConsoleText.get().noSystemConsoleAvailable); ConsoleText.get().noSystemConsoleAvailable);
CredentialsProvider.setDefault(c); CredentialsProvider cp = new ChainingCredentialsProvider(
new NetRCCredentialsProvider(), c);
CredentialsProvider.setDefault(cp);
} }
private final Console cons = System.console(); private final Console cons = System.console();

5
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) private void show(final AnyObjectId id, final String name)
throws IOException { throws IOException {
outw.print(id.name()); outw.print(id.name());

29
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.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -224,6 +225,25 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
// shouldn't throw anything // shouldn't throw anything
} }
/**
* 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 * Create pack basing on only interesting objects, then precisely verify
* content. No delta reuse here. * content. No delta reuse here.
@ -604,8 +624,17 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
final Set<ObjectId> uninterestings, final boolean thin, final Set<ObjectId> uninterestings, final boolean thin,
final boolean ignoreMissingUninteresting) final boolean ignoreMissingUninteresting)
throws MissingObjectException, IOException { 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; NullProgressMonitor m = NullProgressMonitor.INSTANCE;
writer = new PackWriter(config, db.newObjectReader()); writer = new PackWriter(config, db.newObjectReader());
writer.setUseBitmaps(useBitmaps);
writer.setThin(thin); writer.setThin(thin);
writer.setIgnoreMissingUninteresting(ignoreMissingUninteresting); writer.setIgnoreMissingUninteresting(ignoreMissingUninteresting);
writer.preparePack(m, interestings, uninterestings); writer.preparePack(m, interestings, uninterestings);

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -1847,9 +1847,10 @@ public class PackWriter {
Set<? extends ObjectId> have) Set<? extends ObjectId> have)
throws MissingObjectException, IncorrectObjectTypeException, throws MissingObjectException, IncorrectObjectTypeException,
IOException { IOException {
BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null); BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true);
bitmapWalker.reset(); bitmapWalker.reset();
BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap); BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap,
false);
BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap); BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);
if (useCachedPacks && reuseSupport != null if (useCachedPacks && reuseSupport != null
@ -2049,7 +2050,7 @@ public class PackWriter {
walker = bitmapPreparer.newBitmapWalker(); walker = bitmapPreparer.newBitmapWalker();
BitmapBuilder bitmap = walker.findObjects( BitmapBuilder bitmap = walker.findObjects(
Collections.singleton(cmit), null); Collections.singleton(cmit), null, false);
if (last != null && cmit.isReuseWalker() && !bitmap.contains(last)) if (last != null && cmit.isReuseWalker() && !bitmap.contains(last))
throw new IllegalStateException(MessageFormat.format( throw new IllegalStateException(MessageFormat.format(

14
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; 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, throws MissingObjectException, IncorrectObjectTypeException,
IOException { IOException {
final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder(); final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();
@ -91,9 +91,15 @@ final class PackWriterBitmapWalker {
boolean marked = false; boolean marked = false;
for (ObjectId obj : start) { for (ObjectId obj : start) {
if (!bitmapResult.contains(obj)) { try {
walker.markStart(walker.parseAny(obj)); if (!bitmapResult.contains(obj)) {
marked = true; walker.markStart(walker.parseAny(obj));
marked = true;
}
} catch (MissingObjectException e) {
if (ignoreMissingStart)
continue;
throw e;
} }
} }

131
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;
}
}

12
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, public static Transport open(final Repository local, final String remote,
final Operation op) throws NotSupportedException, final Operation op) throws NotSupportedException,
URISyntaxException, TransportException { URISyntaxException, TransportException {
final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote); if (local != null) {
if (doesNotExist(cfg)) final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote);
return open(local, new URIish(remote), null); if (doesNotExist(cfg))
return open(local, cfg, op); return open(local, new URIish(remote), null);
return open(local, cfg, op);
} else
return open(new URIish(remote));
} }
/** /**

3
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); http = local.getConfig().get(HTTP_KEY);
proxySelector = ProxySelector.getDefault(); proxySelector = ProxySelector.getDefault();
if (getCredentialsProvider() == null)
setCredentialsProvider(new NetRCCredentialsProvider());
} }
/** /**

Loading…
Cancel
Save