aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java16
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java3
2 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java
index 70c0463e11..06708b334a 100644
--- a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java
+++ b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java
@@ -11,6 +11,7 @@ package org.eclipse.jgit.lfs.server.fs;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.nio.file.Files;
@@ -29,6 +30,7 @@ import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathFilter;
@@ -128,4 +130,18 @@ public class PushTest extends LfsServerTest {
server.getRequests().toString());
}
+ @Test
+ public void testDeleteBranch() throws Exception {
+ String branch = "new-branch";
+ git.branchCreate().setName(branch).call();
+
+ String destRef = Constants.R_HEADS + branch;
+ git.push().setRefSpecs(new RefSpec().setSource(branch).setDestination(destRef)).call();
+
+ // Should not fail on push.
+ git.branchDelete().setBranchNames(branch).setForce(true).call();
+ git.push().setRefSpecs(new RefSpec().setSource(null).setDestination(destRef)).call();
+
+ assertTrue(server.getRequests().isEmpty());
+ }
}
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java
index d6ce855794..ebf46e080e 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java
@@ -113,6 +113,9 @@ public class LfsPrePushHook extends PrePushHook {
try (ObjectWalk walk = new ObjectWalk(getRepository())) {
for (RemoteRefUpdate up : refs) {
+ if (up.isDelete()) {
+ continue;
+ }
walk.setRewriteParents(false);
excludeRemoteRefs(walk);
walk.markStart(walk.parseCommit(up.getNewObjectId()));