Merge "Fix NPE when _revisionNumber in ChangeMessageInfo is null"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
index 384c089..b2675c4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
@@ -207,13 +207,7 @@
   private AccountGroup createGroup(Input input, GroupInfo info) throws OrmException,
       ResourceConflictException, NoSuchAccountException, BadRequestException,
       IOException, PreconditionFailedException, MethodNotAllowedException {
-    AccountGroup.Id groupId = new AccountGroup.Id(db.nextAccountGroupId());
-    AccountGroup.UUID uuid = new AccountGroup.UUID(info.id);
-    AccountGroup group =
-        new AccountGroup(new AccountGroup.NameKey(info.name), groupId, uuid);
-    group.setVisibleToAll(cfg.getBoolean("groups", "newGroupsVisibleToAll",
-        false));
-    group.setDescription(info.description);
+    AccountGroup group = createAccountGroup(info);
     AccountGroupName gn = new AccountGroupName(group);
     // first insert the group name to validate that the group name hasn't
     // already been used to create another group
@@ -243,14 +237,25 @@
       db.accountGroups().upsert(Collections.singleton(group));
     }
 
-    addMembers(groupId, info.members);
-    addGroups(input, groupId, info.name, info.includes);
+    addMembers(group.getId(), info.members);
+    addGroups(input, group.getId(), info.name, info.includes);
 
     groupCache.evict(group);
 
     return group;
   }
 
+  private AccountGroup createAccountGroup(GroupInfo info) throws OrmException {
+    AccountGroup.Id groupId = new AccountGroup.Id(db.nextAccountGroupId());
+    AccountGroup.UUID uuid = new AccountGroup.UUID(info.id);
+    AccountGroup group =
+        new AccountGroup(new AccountGroup.NameKey(info.name), groupId, uuid);
+    group.setVisibleToAll(cfg.getBoolean("groups", "newGroupsVisibleToAll",
+        false));
+    group.setDescription(info.description);
+    return group;
+  }
+
   private void addMembers(AccountGroup.Id groupId, List<AccountInfo> members)
       throws OrmException, NoSuchAccountException, BadRequestException,
       IOException {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java
index d37bf9f..c63db70 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java
@@ -14,7 +14,6 @@
 
 package com.googlesource.gerrit.plugins.importer;
 
-import com.google.common.base.Strings;
 import com.google.common.collect.Maps;
 import com.google.common.io.Files;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
@@ -27,6 +26,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Locale;
@@ -41,7 +41,7 @@
   @Option(name = "--match", metaVar = "MATCH",
       usage = "List only projects containing this substring, case insensitive")
   public void setMatch(String match) {
-    this.match = match.toLowerCase();
+    this.match = match.toLowerCase(Locale.ENGLISH);
   }
 
   private String match;
@@ -62,15 +62,21 @@
   }
 
   private Collection<File> listImportFiles() {
-    match = Strings.nullToEmpty(match).toLowerCase(Locale.ENGLISH);
     Collection<File> importFiles = new HashSet<>();
-    for (File f : Files.fileTreeTraverser().preOrderTraversal(projects.FS_LAYOUT.getLockRoot())) {
+    File lockRoot = projects.FS_LAYOUT.getLockRoot();
+    Path lockRootPath = lockRoot.toPath();
+    for (File f : Files.fileTreeTraverser().preOrderTraversal(lockRoot)) {
       if (f.isFile()
           && !f.getName().endsWith(".lock")
-          && f.getName().toLowerCase(Locale.ENGLISH).contains(match)) {
+          && matches(lockRootPath.relativize(f.toPath()))) {
         importFiles.add(f);
       }
     }
     return importFiles;
   }
+
+  private boolean matches(Path p) {
+    return match == null
+        || p.toString().toLowerCase(Locale.ENGLISH).contains(match);
+  }
 }
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
index 838fe6d..9443a4b 100644
--- a/src/main/resources/Documentation/about.md
+++ b/src/main/resources/Documentation/about.md
@@ -80,6 +80,9 @@
 * User accounts must have a username set.
 * User accounts must exist in the target Gerrit server unless auth type
   is 'LDAP', 'HTTP\_LDAP' or 'CLIENT\_SSL\_CERT\_LDAP'.
+* For auth type 'LDAP', 'HTTP\_LDAP' or 'CLIENT\_SSL\_CERT\_LDAP' both,
+  the source and the target Gerrit server must be connected to the same
+  LDAP instance.
 
 For auth type 'LDAP', 'HTTP\_LDAP' or 'CLIENT\_SSL\_CERT\_LDAP' missing
 user accounts are automatically created. The public SSH keys of a user