Do not try to copy labels with value == 0

When calculating the inferred approvals for the copied
labels, the ones with value == 0 would never be stored
and therefore should not be selected.

Selecting an approval with a value == 0 causes the change
to receive a series of empty change notes which would
cause unneeded noise and create redundant Git objects
and commits.

Release-Notes: skip
Change-Id: I660e350f6f08fc75803f3e34cb00a391f19c3d88
diff --git a/java/com/google/gerrit/server/approval/ApprovalsUtil.java b/java/com/google/gerrit/server/approval/ApprovalsUtil.java
index 08ea6bc..77ac2e2 100644
--- a/java/com/google/gerrit/server/approval/ApprovalsUtil.java
+++ b/java/com/google/gerrit/server/approval/ApprovalsUtil.java
@@ -383,13 +383,15 @@
     }
 
     for (PatchSetApproval psa : inferred) {
-      if (approvalTable.contains(psa.labelId(), psa.accountId())) {
-        Short v = approvalTable.get(psa.labelId(), psa.accountId());
-        if (v.shortValue() != psa.value()) {
+      if (psa.value() != 0) {
+        if (approvalTable.contains(psa.labelId(), psa.accountId())) {
+          Short v = approvalTable.get(psa.labelId(), psa.accountId());
+          if (v.shortValue() != psa.value()) {
+            changeUpdate.putCopiedApproval(psa);
+          }
+        } else {
           changeUpdate.putCopiedApproval(psa);
         }
-      } else {
-        changeUpdate.putCopiedApproval(psa);
       }
     }
   }