aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java37
2 files changed, 35 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
index 7d7b3ee0a0..2b4deb32f0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
@@ -204,8 +204,13 @@ class FetchProcess {
BatchRefUpdate batch = transport.local.getRefDatabase()
.newBatchUpdate()
- .setAllowNonFastForwards(true)
- .setRefLogMessage("fetch", true); //$NON-NLS-1$
+ .setAllowNonFastForwards(true);
+
+ // Generate reflog only when fetching updates and not at the first clone
+ if (initialBranch == null) {
+ batch.setRefLogMessage("fetch", true); //$NON-NLS-1$
+ }
+
try (RevWalk walk = new RevWalk(transport.local)) {
walk.setRetainBody(false);
if (monitor instanceof BatchingProgressMonitor) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 0a7eb17f05..6cb8fe43c0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -39,6 +39,7 @@ import static org.eclipse.jgit.transport.GitProtocolConstants.VERSION_2_REQUEST;
import static org.eclipse.jgit.util.RefMap.toRefMap;
import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
@@ -105,7 +106,7 @@ import org.eclipse.jgit.util.io.TimeoutOutputStream;
/**
* Implements the server side of a fetch connection, transmitting objects.
*/
-public class UploadPack {
+public class UploadPack implements Closeable {
/** Policy the server uses to validate client requests */
public enum RequestPolicy {
/** Client may only ask for objects the server advertised a reference for. */
@@ -733,6 +734,17 @@ public class UploadPack {
&& clientRequestedV2;
}
+ @Override
+ public void close() {
+ if (timer != null) {
+ try {
+ timer.terminate();
+ } finally {
+ timer = null;
+ }
+ }
+ }
+
/**
* Execute the upload task on the socket.
*
@@ -780,6 +792,8 @@ public class UploadPack {
throw new UploadPackInternalServerErrorException(err);
}
throw err;
+ } finally {
+ close();
}
}
@@ -789,6 +803,10 @@ public class UploadPack {
* <p>
* If the client passed extra parameters (e.g., "version=2") through a side
* channel, the caller must call setExtraParameters first to supply them.
+ * Callers of this method should call {@link #close()} to terminate the
+ * internal interrupt timer thread. If the caller fails to terminate the
+ * thread, it will (eventually) terminate itself when the InterruptTimer
+ * instance is garbage collected.
*
* @param input
* raw input to read client commands from. Caller must ensure the
@@ -845,13 +863,6 @@ public class UploadPack {
} finally {
msgOut = NullOutputStream.INSTANCE;
walk.close();
- if (timer != null) {
- try {
- timer.terminate();
- } finally {
- timer = null;
- }
- }
}
}
@@ -1998,12 +2009,16 @@ public class UploadPack {
throws IOException {
ObjectReader reader = up.getRevWalk().getObjectReader();
+ Set<ObjectId> directlyVisibleObjects = refIdSet(visibleRefs);
+ List<ObjectId> nonTipWants = notAdvertisedWants.stream()
+ .filter(not(directlyVisibleObjects::contains))
+ .collect(Collectors.toList());
try (RevWalk walk = new RevWalk(reader)) {
walk.setRetainBody(false);
// Missing "wants" throw exception here
List<RevObject> wantsAsObjs = objectIdsToRevObjects(walk,
- notAdvertisedWants);
+ nonTipWants);
List<RevCommit> wantsAsCommits = wantsAsObjs.stream()
.filter(obj -> obj instanceof RevCommit)
.map(obj -> (RevCommit) obj)
@@ -2063,6 +2078,10 @@ public class UploadPack {
}
}
+ private static <T> Predicate<T> not(Predicate<T> t) {
+ return t.negate();
+ }
+
static Stream<Ref> importantRefsFirst(
Collection<Ref> visibleRefs) {
Predicate<Ref> startsWithRefsHeads = ref -> ref.getName()