Browse Source

Merge "Fix resolving of relative file URIs in TransportLocal"

tags/v2.1.0.201209190230-r
Robin Rosenberg 12 years ago
parent
commit
0ec1db820d

+ 13
- 0
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java View File

import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.SampleDataRepositoryTestCase; import org.eclipse.jgit.lib.SampleDataRepositoryTestCase;
import org.eclipse.jgit.storage.file.FileRepository;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
assertEquals(ObjectId.zeroId(), tru.getOldObjectId()); assertEquals(ObjectId.zeroId(), tru.getOldObjectId());
} }


@Test
public void testLocalTransportWithRelativePath() throws Exception {
FileRepository other = createWorkRepository();
String otherDir = other.getWorkTree().getName();

RemoteConfig config = new RemoteConfig(db.getConfig(), "other");
config.addURI(new URIish("../" + otherDir));

// Should not throw NoRemoteRepositoryException
transport = Transport.open(db, config);
}

@Test @Test
public void testSpi() { public void testSpi() {
List<TransportProtocol> protocols = Transport.getTransportProtocols(); List<TransportProtocol> protocols = Transport.getTransportProtocols();

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java View File

@Override @Override
public Transport open(URIish uri, Repository local, String remoteName) public Transport open(URIish uri, Repository local, String remoteName)
throws NoRemoteRepositoryException { throws NoRemoteRepositoryException {
File localPath = local.isBare() ? local.getDirectory() : local.getWorkTree();
File path = local.getFS().resolve(localPath, uri.getPath());
// If the reference is to a local file, C Git behavior says // If the reference is to a local file, C Git behavior says
// assume this is a bundle, since repositories are directories. // assume this is a bundle, since repositories are directories.
//
File path = local.getFS().resolve(new File("."), uri.getPath());
if (path.isFile()) if (path.isFile())
return new TransportBundleFile(local, uri, path); return new TransportBundleFile(local, uri, path);



Loading…
Cancel
Save