Merge changes I651c570b,I0d571918

* changes:
  Switch padding to margin in header
  Fix Gerrit global scoping issue
diff --git a/java/com/google/gerrit/acceptance/ProjectResetter.java b/java/com/google/gerrit/acceptance/ProjectResetter.java
index 1fed8f8..76ae4b0 100644
--- a/java/com/google/gerrit/acceptance/ProjectResetter.java
+++ b/java/com/google/gerrit/acceptance/ProjectResetter.java
@@ -214,7 +214,7 @@
     for (Map.Entry<Project.NameKey, Collection<String>> e :
         refsPatternByProject.asMap().entrySet()) {
       try (Repository repo = repoManager.openRepository(e.getKey())) {
-        Collection<Ref> refs = repo.getAllRefs().values();
+        Collection<Ref> refs = repo.getRefDatabase().getRefs();
         for (String refPattern : e.getValue()) {
           RefPatternMatcher matcher = RefPatternMatcher.getMatcher(refPattern);
           for (Ref ref : refs) {
diff --git a/java/com/google/gerrit/httpd/raw/IndexServlet.java b/java/com/google/gerrit/httpd/raw/IndexServlet.java
index 90b25d9..a414e84 100644
--- a/java/com/google/gerrit/httpd/raw/IndexServlet.java
+++ b/java/com/google/gerrit/httpd/raw/IndexServlet.java
@@ -37,7 +37,8 @@
   private static final long serialVersionUID = 1L;
   protected final byte[] indexSource;
 
-  IndexServlet(String canonicalURL, @Nullable String cdnPath, @Nullable String faviconPath)
+  IndexServlet(
+      @Nullable String canonicalURL, @Nullable String cdnPath, @Nullable String faviconPath)
       throws URISyntaxException {
     String resourcePath = "com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy";
     SoyFileSet.Builder builder = SoyFileSet.builder();
@@ -62,7 +63,7 @@
     }
   }
 
-  static String computeCanonicalPath(String canonicalURL) throws URISyntaxException {
+  static String computeCanonicalPath(@Nullable String canonicalURL) throws URISyntaxException {
     if (Strings.isNullOrEmpty(canonicalURL)) {
       return "";
     }
diff --git a/java/com/google/gerrit/server/patch/PatchListEntry.java b/java/com/google/gerrit/server/patch/PatchListEntry.java
index 325f78d..6b1a153 100644
--- a/java/com/google/gerrit/server/patch/PatchListEntry.java
+++ b/java/com/google/gerrit/server/patch/PatchListEntry.java
@@ -26,6 +26,7 @@
 import static com.google.gerrit.server.ioutil.BasicSerialization.writeFixInt64;
 import static com.google.gerrit.server.ioutil.BasicSerialization.writeString;
 import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -41,7 +42,6 @@
 import java.util.List;
 import java.util.Set;
 import org.eclipse.jgit.diff.Edit;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.patch.CombinedFileHeader;
 import org.eclipse.jgit.patch.FileHeader;
 import org.eclipse.jgit.util.IntList;
@@ -223,7 +223,7 @@
       if (header[e - 1] == '\n') {
         e--;
       }
-      headerLines.add(RawParseUtils.decode(Constants.CHARSET, header, b, e));
+      headerLines.add(RawParseUtils.decode(UTF_8, header, b, e));
     }
     return headerLines;
   }
diff --git a/java/com/google/gerrit/server/submit/GitModules.java b/java/com/google/gerrit/server/submit/GitModules.java
index 1fccbdd..f616e92 100644
--- a/java/com/google/gerrit/server/submit/GitModules.java
+++ b/java/com/google/gerrit/server/submit/GitModules.java
@@ -77,14 +77,15 @@
           return;
         }
       }
-      BlobBasedConfig bbc;
+      BlobBasedConfig config;
       try {
-        bbc = new BlobBasedConfig(null, or.repo, commit, GIT_MODULES);
+        config = new BlobBasedConfig(null, or.repo, commit, GIT_MODULES);
       } catch (ConfigInvalidException e) {
         throw new IOException(
             "Could not read .gitmodules of super project: " + branch.getParentKey(), e);
       }
-      subscriptions = new SubmoduleSectionParser(bbc, canonicalWebUrl, branch).parseAllSections();
+      subscriptions =
+          new SubmoduleSectionParser(config, canonicalWebUrl, branch).parseAllSections();
     } catch (NoSuchProjectException e) {
       throw new IOException(e);
     }
diff --git a/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java b/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java
index a92b7fd..f05d1d7 100644
--- a/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java
+++ b/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java
@@ -43,20 +43,20 @@
  */
 public class SubmoduleSectionParser {
 
-  private final Config bbc;
+  private final Config config;
   private final String canonicalWebUrl;
   private final Branch.NameKey superProjectBranch;
 
   public SubmoduleSectionParser(
-      Config bbc, String canonicalWebUrl, Branch.NameKey superProjectBranch) {
-    this.bbc = bbc;
+      Config config, String canonicalWebUrl, Branch.NameKey superProjectBranch) {
+    this.config = config;
     this.canonicalWebUrl = canonicalWebUrl;
     this.superProjectBranch = superProjectBranch;
   }
 
   public Set<SubmoduleSubscription> parseAllSections() {
     Set<SubmoduleSubscription> parsedSubscriptions = new HashSet<>();
-    for (String id : bbc.getSubsections("submodule")) {
+    for (String id : config.getSubsections("submodule")) {
       final SubmoduleSubscription subscription = parse(id);
       if (subscription != null) {
         parsedSubscriptions.add(subscription);
@@ -66,9 +66,9 @@
   }
 
   private SubmoduleSubscription parse(String id) {
-    final String url = bbc.getString("submodule", id, "url");
-    final String path = bbc.getString("submodule", id, "path");
-    String branch = bbc.getString("submodule", id, "branch");
+    final String url = config.getString("submodule", id, "url");
+    final String path = config.getString("submodule", id, "path");
+    String branch = config.getString("submodule", id, "branch");
 
     try {
       if (url != null
diff --git a/lib/jgit/jgit.bzl b/lib/jgit/jgit.bzl
index 7191901..816c3a3 100644
--- a/lib/jgit/jgit.bzl
+++ b/lib/jgit/jgit.bzl
@@ -1,6 +1,6 @@
 load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_CENTRAL", "MAVEN_LOCAL", "maven_jar")
 
-_JGIT_VERS = "5.0.3.201809091024-r"
+_JGIT_VERS = "5.1.1.201809181055-r"
 
 _DOC_VERS = _JGIT_VERS  # Set to _JGIT_VERS unless using a snapshot
 
@@ -40,28 +40,28 @@
         name = "jgit-lib",
         artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
         repository = _JGIT_REPO,
-        sha1 = "0afec2df3ff8835bc4d5c279d14fad0daae6dd93",
-        src_sha1 = "e2c978064e2a46b260bbda0d8c393ed741046420",
+        sha1 = "64dfe41b3c152bb9b7158b214e28467cb1217153",
+        src_sha1 = "ff6ab018897cf4213b905e156ac5930bad2bdff1",
         unsign = True,
     )
     maven_jar(
         name = "jgit-servlet",
         artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
         repository = _JGIT_REPO,
-        sha1 = "8fb0f9b6c38ac6fce60f2ead740e03dd79c3c288",
+        sha1 = "22fd6827fbb6135efd813271185a91f8615538eb",
         unsign = True,
     )
     maven_jar(
         name = "jgit-archive",
         artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
         repository = _JGIT_REPO,
-        sha1 = "72a157ce261f3eb938d9e0ee83d7c9700aa7d736",
+        sha1 = "bfbbdd6aa1893db14f346913aad3f9898b2fe01d",
     )
     maven_jar(
         name = "jgit-junit",
         artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
         repository = _JGIT_REPO,
-        sha1 = "eb430358d96dedd923e4075cd54a7db4cab51ca2",
+        sha1 = "6de6de74053d7c28100fe128255d7382a939fe99",
         unsign = True,
     )
 
diff --git a/plugins/reviewnotes b/plugins/reviewnotes
index 920f28b..54525ff 160000
--- a/plugins/reviewnotes
+++ b/plugins/reviewnotes
@@ -1 +1 @@
-Subproject commit 920f28b46021d9c49fac09d869aa4040d13796e7
+Subproject commit 54525ffaed5e8925d97657a622532a00a0006347
diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
index 6c7903d..db14fc8 100644
--- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
+++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
@@ -72,7 +72,7 @@
 
     /**
      * Register a listener for layer updates.
-     * @param {Function<Number, Number, String>} fn The update handler function.
+     * @param {function(number, number, string)} fn The update handler function.
      *     Should accept as arguments the line numbers for the start and end of
      *     the update and the side as a string.
      */