summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java28
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java2
2 files changed, 29 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java
index 459ca876d1..68e0129525 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java
@@ -308,6 +308,34 @@ public class PushCertificateStoreTest {
}
@Test
+ public void putMatchingWithNoMatchingRefsInBatchOnEmptyRef()
+ throws Exception {
+ PushCertificate addMaster = newCert(
+ command(zeroId(), ID1, "refs/heads/master"),
+ command(zeroId(), ID2, "refs/heads/branch"));
+ store.put(addMaster, newIdent(), Collections.<ReceiveCommand> emptyList());
+ BatchRefUpdate batch = repo.getRefDatabase().newBatchUpdate();
+ assertFalse(store.save(batch));
+ assertEquals(0, batch.getCommands().size());
+ }
+
+ @Test
+ public void putMatchingWithNoMatchingRefsInBatchOnNonEmptyRef()
+ throws Exception {
+ PushCertificate addMaster = newCert(
+ command(zeroId(), ID1, "refs/heads/master"));
+ store.put(addMaster, newIdent());
+ assertEquals(NEW, store.save());
+
+ PushCertificate addBranch = newCert(
+ command(zeroId(), ID2, "refs/heads/branch"));
+ store.put(addBranch, newIdent(), Collections.<ReceiveCommand> emptyList());
+ BatchRefUpdate batch = repo.getRefDatabase().newBatchUpdate();
+ assertFalse(store.save(batch));
+ assertEquals(0, batch.getCommands().size());
+ }
+
+ @Test
public void putMatchingWithSomeMatchingRefs() throws Exception {
PushCertificate addMasterAndBranch = newCert(
command(zeroId(), ID1, "refs/heads/master"),
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
index 389bd689ce..d8672d5a2b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
@@ -401,7 +401,7 @@ public class PushCertificateStore implements AutoCloseable {
*/
public boolean save(BatchRefUpdate batch) throws IOException {
ObjectId newId = write();
- if (newId == null) {
+ if (newId == null || newId.equals(commit)) {
return false;
}
batch.addCommand(new ReceiveCommand(