Merge "Documentation: both gerrit system using same LDAP"
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);
+  }
 }