@Override public UploadPack create(DaemonClient req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { UploadPack up = new UploadPack(db); up.setTimeout(getTimeout()); up.setPackConfig(getPackConfig()); return up; } };
@Override public void run() { try { final UploadPack rp = uploadPackFactory.create(req, remote); rp.upload(out_r, in_w, null); } catch (ServiceNotEnabledException e) { // Ignored. Client cannot use this repository. } catch (ServiceNotAuthorizedException e) { // Ignored. Client cannot use this repository. } catch (IOException err) { // Client side of the pipes should report the problem. err.printStackTrace(); } catch (RuntimeException err) { // Client side will notice we went away, and report. err.printStackTrace(); } finally { try { out_r.close(); } catch (IOException e2) { // Ignore close failure, we probably crashed above. } try { in_w.close(); } catch (IOException e2) { // Ignore close failure, we probably crashed above. } remote.close(); } } };
/** {@inheritDoc} */ @Override public void advertiseRefs(UploadPack uploadPack) throws ServiceMayNotContinueException { uploadPack.setAdvertisedRefs(getAdvertisedRefs( uploadPack.getRepository(), uploadPack.getRevWalk())); }
@Override public void checkWants(UploadPack up, List<ObjectId> wants) throws PackProtocolException, IOException { if (!up.isBiDirectionalPipe()) new ReachableCommitTipRequestValidator().checkWants(up, wants); else if (!wants.isEmpty()) { Set<ObjectId> refIds = refIdSet(up.getRepository().getRefDatabase().getRefs()); for (ObjectId obj : wants) { if (!refIds.contains(obj)) throw new WantNotValidException(obj); } } } }
@Override protected void runImpl() throws IOException, Failure { final UploadPack up = new UploadPack(repo); up.setPackConfig(config.getPackConfig()); up.setTimeout(config.getTimeout()); try { up.upload(in, out, err); } catch (InterruptedIOException err) { throw new Failure(128, "fatal: client IO read/write timeout", err); } } }
UploadPack createUploadPack(Repository dst) { return new UploadPack(dst); }
@Override protected void execute(final FileSystemUser user, final Repository repository, final InputStream in, final OutputStream out, final OutputStream err, final JGitFileSystem fileSystem) { final UploadPack up = new UploadPack(repository); final PackConfig config = new PackConfig(repository); config.setCompressionLevel(Deflater.BEST_COMPRESSION); up.setPackConfig(config); up.setRefFilter(new HiddenBranchRefFilter()); try { up.upload(in, out, err); } catch (final IOException ignored) { } } }
@Override protected void run() throws Exception { final org.eclipse.jgit.transport.UploadPack up; try { FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED); db = key.open(true /* must exist */); } catch (RepositoryNotFoundException notFound) { throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath())); } up = new org.eclipse.jgit.transport.UploadPack(db); if (0 <= timeout) up.setTimeout(timeout); up.upload(ins, outs, errs); } }
try { if (biDirectionalPipe) sendAdvertisedRefs(new PacketLineOutRefAdvertiser(pckOut)); else if (requestValidator instanceof AnyRequestValidator) advertised = Collections.emptySet(); else advertised = refIdSet(getAdvertisedOrDefaultRefs().values()); verifyClientShallow(req.getClientShallowCommits()); computeShallowsAndUnshallows(req, shallow -> { pckOut.writeString("shallow " + shallow.name() + '\n'); //$NON-NLS-1$ }, unshallow -> { sendPack = negotiate(req, accumulator); accumulator.timeNegotiating += System.currentTimeMillis() - negotiateStart; sendPack(accumulator, req, refs == null ? null : refs.values(), unshallowCommits, Collections.emptyList());
final UploadPack up = new UploadPack(db); up.setTimeout(getTimeout()); up.setRefFilter(new HiddenBranchRefFilter()); final PackConfig config = new PackConfig(db); config.setCompressionLevel(Deflater.BEST_COMPRESSION); up.setPackConfig(config);
@Override public UploadPack create(HttpServletRequest req, Repository repo) throws ServiceNotEnabledException, ServiceNotAuthorizedException { // The Resolver above already checked READ access for us. // UploadPack up = new UploadPack(repo); up.setPackConfig(packConfig); return up; } }
try { if (biDirectionalPipe) sendAdvertisedRefs(new PacketLineOutRefAdvertiser(pckOut)); else if (requestValidator instanceof AnyRequestValidator) advertised = Collections.emptySet(); else advertised = refIdSet(getAdvertisedOrDefaultRefs().values()); recvWants(); if (wantIds.isEmpty()) { preUploadHook.onBeginNegotiateRound(this, wantIds, 0); verifyClientShallow(); if (depth != 0) processShallow(); if (!clientShallowCommits.isEmpty()) walk.assumeShallow(clientShallowCommits); sendPack = negotiate(); } catch (ServiceMayNotContinueException err) { if (!err.isOutput() && err.getMessage() != null) { sendPack();
@Override protected void advertise(HttpServletRequest req, PacketLineOutRefAdvertiser pck) throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { UploadPack up = (UploadPack) req.getAttribute(ATTRIBUTE_HANDLER); try { up.setBiDirectionalPipe(false); up.sendAdvertisedRefs(pck); } finally { up.getRevWalk().release(); } } }
up.setBiDirectionalPipe(false); rsp.setContentType(UPLOAD_PACK_RESULT_TYPE); up.upload(getInputStream(req), out, null); out.close(); log(up.getRepository(), e.getCause()); consumeRequestBody(req); out.close(); log(up.getRepository(), e); if (!rsp.isCommitted()) { rsp.reset();
@Override protected void execute(final DaemonClient dc, final Repository db, @Nullable Collection<String> extraParameters) throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { UploadPack up = uploadPackFactory.create(dc, db); InputStream in = dc.getInputStream(); OutputStream out = dc.getOutputStream(); if (extraParameters != null) { up.setExtraParameters(extraParameters); } up.upload(in, out, null); } }, new DaemonService("receive-pack", "receivepack") { //$NON-NLS-1$ //$NON-NLS-2$
up.setBiDirectionalPipe(false); rsp.setContentType(UPLOAD_PACK_RESULT_TYPE); up.upload(getInputStream(req), out, null); out.close();
public void checkWants(UploadPack up, List<ObjectId> wants) throws PackProtocolException, IOException { checkNotAdvertisedWants(up.getRevWalk(), wants, refIdSet(up.getRepository().getRefDatabase().getRefs(ALL).values())); } }
public void checkWants(UploadPack up, List<ObjectId> wants) throws PackProtocolException, IOException { checkNotAdvertisedWants(up.getRevWalk(), wants, refIdSet(up.getAdvertisedRefs().values())); } }
ObjectReader reader = up.getRevWalk().getObjectReader(); try (RevWalk walk = new RevWalk(reader)) { AsyncRevObjectQueue q = walk.parseAny(notAdvertisedWants, true); checkNotAdvertisedWantsUsingBitmap( reader, bitmapIndex,
/** * Generate an advertisement of available refs and capabilities. * * @param adv * the advertisement formatter. * @throws java.io.IOException * the formatter failed to write an advertisement. * @throws org.eclipse.jgit.transport.ServiceMayNotContinueException * the hook denied advertisement. */ public void sendAdvertisedRefs(RefAdvertiser adv) throws IOException, ServiceMayNotContinueException { sendAdvertisedRefs(adv, null); }