private void updateFETCH_HEAD(FetchResult result) throws IOException { File meta = transport.local.getDirectory(); if (meta == null) return; final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD")); //$NON-NLS-1$ try { if (lock.lock()) { try (Writer w = new OutputStreamWriter( lock.getOutputStream(), UTF_8)) { for (FetchHeadRecord h : fetchHeadUpdates) { h.write(w); result.add(h); } } lock.commit(); } } finally { lock.unlock(); } }
private void addUpdateBatchCommands(FetchResult result, BatchRefUpdate batch) throws TransportException { Map<String, ObjectId> refs = new HashMap<>(); for (TrackingRefUpdate u : localUpdates) { // Try to skip duplicates if they'd update to the same object ID ObjectId existing = refs.get(u.getLocalName()); if (existing == null) { refs.put(u.getLocalName(), u.getNewObjectId()); result.add(u); batch.addCommand(u.asReceiveCommand()); } else if (!existing.equals(u.getNewObjectId())) { throw new TransportException(MessageFormat .format(JGitText.get().duplicateRef, u.getLocalName())); } } }
private void deleteTrackingRef(final FetchResult result, final BatchRefUpdate batch, final RefSpec spec, final Ref localRef) { if (localRef.getObjectId() == null) return; TrackingRefUpdate update = new TrackingRefUpdate( true, spec.getSource(), localRef.getName(), localRef.getObjectId(), ObjectId.zeroId()); result.add(update); batch.addCommand(update.asReceiveCommand()); }
private void updateFETCH_HEAD(final FetchResult result) throws IOException { File meta = transport.local.getDirectory(); if (meta == null) return; final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD")); //$NON-NLS-1$ try { if (lock.lock()) { final Writer w = new OutputStreamWriter(lock.getOutputStream()); try { for (final FetchHeadRecord h : fetchHeadUpdates) { h.write(w); result.add(h); } } finally { w.close(); } lock.commit(); } } finally { lock.unlock(); } }
private void updateFETCH_HEAD(FetchResult result) throws IOException { File meta = transport.local.getDirectory(); if (meta == null) return; final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD")); //$NON-NLS-1$ try { if (lock.lock()) { try (Writer w = new OutputStreamWriter( lock.getOutputStream(), UTF_8)) { for (FetchHeadRecord h : fetchHeadUpdates) { h.write(w); result.add(h); } } lock.commit(); } } finally { lock.unlock(); } }
private void addUpdateBatchCommands(FetchResult result, BatchRefUpdate batch) throws TransportException { Map<String, ObjectId> refs = new HashMap<>(); for (TrackingRefUpdate u : localUpdates) { // Try to skip duplicates if they'd update to the same object ID ObjectId existing = refs.get(u.getLocalName()); if (existing == null) { refs.put(u.getLocalName(), u.getNewObjectId()); result.add(u); batch.addCommand(u.asReceiveCommand()); } else if (!existing.equals(u.getNewObjectId())) { throw new TransportException(MessageFormat .format(JGitText.get().duplicateRef, u.getLocalName())); } } }
private void deleteTrackingRef(final FetchResult result, final BatchRefUpdate batch, final RefSpec spec, final Ref localRef) { if (localRef.getObjectId() == null) return; TrackingRefUpdate update = new TrackingRefUpdate( true, spec.getSource(), localRef.getName(), localRef.getObjectId(), ObjectId.zeroId()); result.add(update); batch.addCommand(update.asReceiveCommand()); }
private void deleteTrackingRef(final FetchResult result, final BatchRefUpdate batch, final RefSpec spec, final Ref localRef) { if (localRef.getObjectId() == null) return; TrackingRefUpdate update = new TrackingRefUpdate( true, spec.getSource(), localRef.getName(), localRef.getObjectId(), ObjectId.zeroId()); result.add(update); batch.addCommand(update.asReceiveCommand()); }
deleteStaleTrackingRefs(result, batch); for (TrackingRefUpdate u : localUpdates) { result.add(u); batch.addCommand(u.asReceiveCommand());