Keep status:closed's limit below MySQL Connector/J's hard limit

Since MySQL Connector/J 5.1.21 does not allow limits above 50M rows
and aborts them with

  java.sql.SQLException: setMaxRows() out of range. 2147483647 > 50000000.

we cannot use MAX_VALUE as limit for plain "status:closed" queries. As
50M seems big enough for general use anyways, we use the 50M limit.

Bug: 2392
Change-Id: I70d3446b3fd3a140f7cdd0591803bec5df050484
Merge "Keep status:closed's limit below MySQL Connector/J's hard limit" into stable-2.8
Add newline on commit messages cherry-picked from UI and REST API

If a commit is cherry-picked from the UI or via the REST API, the
trailing newline on the end of the commit message gets lost.

This means that when a commit is cherry picked in the UI, and the
"(cherry picked from commit ...)" line is added, if the resulting
commit is then cherry-picked again from the command line with `-x`,
the next "(cherry picked from commit ...)" line gets appended on
to the end of the line, rather than on a new line.

Make sure a trailing newline is always added on the end of the
commit message of cherry pick commits.

Change-Id: If1102458658dc194034111cbd65b937478002bf1
Fix IllegalArgumentException when running query with limit:0

Running the query:

  ssh -p 29418 user@review gerrit query status:open limit:0

Causes an exception:

  java.lang.IllegalArgumentException: numHits must be > 0;
  please use TotalHitCountCollector if you just need the total
  hit count

  at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:1120)

And this results in the query returning "Internal server error".

Add a check to ensure that the limit is always > 0.

Change-Id: I92260c6d6431c7950909c8a8ffceada7e9f690a4
Merge "Add newline on commit messages cherry-picked from UI and REST API" into stable-2.8