public BasePackFetchConnection(final PackTransport packTransport) {
super(packTransport);
- final FetchConfig cfg = local.getConfig().get(FetchConfig.KEY);
+ if (local != null) {
+ final FetchConfig cfg = local.getConfig().get(FetchConfig.KEY);
+ allowOfsDelta = cfg.allowOfsDelta;
+ } else {
+ allowOfsDelta = true;
+ }
includeTags = transport.getTagOpt() != TagOpt.NO_TAGS;
thinPack = transport.isFetchThin();
- allowOfsDelta = cfg.allowOfsDelta;
-
- walk = new RevWalk(local);
- reachableCommits = new RevCommitList<RevCommit>();
- REACHABLE = walk.newFlag("REACHABLE"); //$NON-NLS-1$
- COMMON = walk.newFlag("COMMON"); //$NON-NLS-1$
- STATE = walk.newFlag("STATE"); //$NON-NLS-1$
- ADVERTISED = walk.newFlag("ADVERTISED"); //$NON-NLS-1$
-
- walk.carry(COMMON);
- walk.carry(REACHABLE);
- walk.carry(ADVERTISED);
+
+ if (local != null) {
+ walk = new RevWalk(local);
+ reachableCommits = new RevCommitList<RevCommit>();
+ REACHABLE = walk.newFlag("REACHABLE"); //$NON-NLS-1$
+ COMMON = walk.newFlag("COMMON"); //$NON-NLS-1$
+ STATE = walk.newFlag("STATE"); //$NON-NLS-1$
+ ADVERTISED = walk.newFlag("ADVERTISED"); //$NON-NLS-1$
+
+ walk.carry(COMMON);
+ walk.carry(REACHABLE);
+ walk.carry(ADVERTISED);
+ } else {
+ walk = null;
+ REACHABLE = null;
+ COMMON = null;
+ STATE = null;
+ ADVERTISED = null;
+ }
}
private static class FetchConfig {
@Override
public void close() {
- walk.release();
+ if (walk != null)
+ walk.release();
super.close();
}
/**
* Open a new transport with no local repository.
+ * <p>
+ * Note that the resulting transport instance can not be used for fetching
+ * or pushing, but only for reading remote refs.
*
* @param uri
* @return new Transport instance
/**
* Begins a new connection for fetching from the remote repository.
+ * <p>
+ * If the transport has no local repository, the fetch connection can only
+ * be used for reading remote refs.
*
* @return a fresh connection to fetch from the remote repository.
* @throws NotSupportedException