diff options
author | Nail Samatov <sanail@yandex.ru> | 2022-01-21 19:30:51 +0300 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2022-01-27 20:55:58 +0100 |
commit | ad098b3b85c58fffd65b7daee03363b1e71d456c (patch) | |
tree | 804de299cc42e8ecc0f9db904d8764d04d5dfecb /org.eclipse.jgit.lfs.server.test | |
parent | 27e554e465d043ed12914fd42554164c9333fc44 (diff) | |
download | jgit-ad098b3b85c58fffd65b7daee03363b1e71d456c.tar.gz jgit-ad098b3b85c58fffd65b7daee03363b1e71d456c.zip |
LFS: Fix error occurring during delete branch
Fix TransportException occurring when deleting
a branch and push that change to remote repository
if BuiltinLFS is used to work with repository.
When finding LFS pointers in RemoteRepUpdate,
LfsPrePushHook fails to open ObjectReader
with new object id equal to ObjectId.zeroId().
If update is a deleting update (new object id is zero id),
we can assume that this update doesn't contain LFS Pointer
and we can skip step with extracting LFS pointer for that
RemoteRefUpdate.
Bug: 578313
Change-Id: Ic4367978338b8234d39d9af0d9674490f79fc22d
Signed-off-by: Nail Samatov <sanail@yandex.ru>
Diffstat (limited to 'org.eclipse.jgit.lfs.server.test')
-rw-r--r-- | org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java | 16 |
1 files changed, 16 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()); + } } |