summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-08-25 16:07:20 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2018-08-25 16:14:22 +0200
commit851f2399515db1f06496b47eefa51a8c5b0c86d7 (patch)
tree28146db175edf15ed0d7d50d7c46e8823ffb9625 /org.eclipse.jgit
parent5786ac991bd28c502613c7cddc7b4fdd01f8346d (diff)
parentcde0e313819c0209eb692820fb32f85e5b034e16 (diff)
downloadjgit-851f2399515db1f06496b47eefa51a8c5b0c86d7.tar.gz
jgit-851f2399515db1f06496b47eefa51a8c5b0c86d7.zip
Merge branch 'stable-5.0'
* stable-5.0: Silence API warning for new ObjectIdSerializer introduced in 4.11.1 Ignore API warnings Fix photon target platform to use photon version of org.eclipse.osgi Update Photon orbit repository to R20180606145124 Suppress warning for trying to delete non-empty directory Fix fetching with duplicate ref updates Fetch(Process): should tolerate duplicate refspecs FetchCommandTest: test add/update/delete fetch Change-Id: I9e7fa37b100a7ea3cbe4104802d36c6f38df9e08 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/.settings/.api_filters18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java36
3 files changed, 34 insertions, 25 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
index b7b49bc658..9f4b761495 100644
--- a/org.eclipse.jgit/.settings/.api_filters
+++ b/org.eclipse.jgit/.settings/.api_filters
@@ -7,22 +7,6 @@
</message_arguments>
</filter>
</resource>
- <resource path="src/org/eclipse/jgit/lib/ObjectIdSerializer.java" type="org.eclipse.jgit.lib.ObjectIdSerializer">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="4.11"/>
- <message_argument value="5.0"/>
- <message_argument value="readWithoutMarker(InputStream)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="4.11"/>
- <message_argument value="5.0"/>
- <message_argument value="writeWithoutMarker(OutputStream, AnyObjectId)"/>
- </message_arguments>
- </filter>
- </resource>
<resource path="src/org/eclipse/jgit/transport/GitProtocolConstants.java" type="org.eclipse.jgit.transport.GitProtocolConstants">
<filter id="337768515">
<message_arguments>
@@ -30,4 +14,4 @@
</message_arguments>
</filter>
</resource>
-</component>
+</component> \ No newline at end of file
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
index 7d2bd4897a..40c6de33fa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
@@ -65,6 +65,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
+import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.DigestInputStream;
@@ -1287,6 +1288,10 @@ public class RefDirectory extends RefDatabase {
for (int i = 0; i < depth; ++i) {
try {
Files.delete(dir.toPath());
+ } catch (DirectoryNotEmptyException e) {
+ // Don't log; normal case when there are other refs with the
+ // same prefix
+ break;
} catch (IOException e) {
LOG.warn("Unable to remove path {}", dir, e); //$NON-NLS-1$
break;
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 ff183c8974..c43ab18c35 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
@@ -203,12 +203,10 @@ class FetchProcess {
((BatchingProgressMonitor) monitor).setDelayStart(
250, TimeUnit.MILLISECONDS);
}
- if (transport.isRemoveDeletedRefs())
+ if (transport.isRemoveDeletedRefs()) {
deleteStaleTrackingRefs(result, batch);
- for (TrackingRefUpdate u : localUpdates) {
- result.add(u);
- batch.addCommand(u.asReceiveCommand());
}
+ addUpdateBatchCommands(result, batch);
for (ReceiveCommand cmd : batch.getCommands()) {
cmd.updateType(walk);
if (cmd.getType() == UPDATE_NONFASTFORWARD
@@ -221,8 +219,11 @@ class FetchProcess {
if (cmd.getResult() == NOT_ATTEMPTED)
cmd.setResult(OK);
}
- } else
+ } else {
batch.execute(walk, monitor);
+ }
+ } catch (TransportException e) {
+ throw e;
} catch (IOException err) {
throw new TransportException(MessageFormat.format(
JGitText.get().failureUpdatingTrackingRef,
@@ -239,6 +240,23 @@ class FetchProcess {
}
}
+ 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 fetchObjects(ProgressMonitor monitor)
throws TransportException {
try {
@@ -479,15 +497,17 @@ class FetchProcess {
private void deleteStaleTrackingRefs(FetchResult result,
BatchRefUpdate batch) throws IOException {
+ Set<Ref> processed = new HashSet<>();
for (Ref ref : localRefs().values()) {
if (ref.isSymbolic()) {
continue;
}
- final String refname = ref.getName();
+ String refname = ref.getName();
for (RefSpec spec : toFetch) {
if (spec.matchDestination(refname)) {
- final RefSpec s = spec.expandFromDestination(refname);
- if (result.getAdvertisedRef(s.getSource()) == null) {
+ RefSpec s = spec.expandFromDestination(refname);
+ if (result.getAdvertisedRef(s.getSource()) == null
+ && processed.add(ref)) {
deleteTrackingRef(result, batch, s, ref);
}
}