Reject command instead of internal error when deleting non-existing ref.

The Git CLI sends DELETE 0...0 0...0 command (i.e. 0 old id) when it
can't get ref from server during negotiation phase. It is unclear why
this happens, but it always causes internal error in gerrit even if
the ref actually exists.

This change explicitly checks old id in the delete command and reject
it with a correct message.

The fix doesn't have tests, because jgit never sends DELETE command
to a server if server doesn't return it during negotiation. Writing
tests require a lot of low-level operation to create and pass the
command to gerrit - this is too complicated comparing to the value
of fix itself.

The change was tested by commenting some jgit code to emulate the behavior of Git CLI. It was confirmed, that:

1) Gerrit always fail if old id is 0 (both for existing and non-existing repos)
2) After the fix, the command is rejected with a correct message.

Google-Bug-Id: b/345164807
Release-Notes: skip
Change-Id: Icafbbdb12a2950d34c957a893c2a4b8587c393c6
diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
index 68061bd..e515dcc 100644
--- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
@@ -1592,6 +1592,15 @@
       } else {
         rejectProhibited(cmd, err.get());
       }
+      if (ObjectId.zeroId().equals(cmd.getOldId())) {
+        // Git CLI sends DELETE 0..0 0...0 when the server doesn't send the deleted ref during
+        // negotiation. The server usually doesn't send it when ref doesn't exist or when it
+        // is not visible to a caller - so the message that the ref doesn't exist should be ok
+        // here.
+        // Without this check, such delete always fails with the "internal error" message, caused
+        // by the checkArgument in the  ChainedReceiveCommands#add.
+        reject(cmd, String.format("The ref %s doesn't exist", cmd.getRefName()));
+      }
     }
   }