Merge branch 'stable-2.11'

* stable-2.11:
  Fix: enable to add a user within a project's ACL using 'user/username'

Change-Id: Ied7cd876f5af4eb9a4c31944b42fe61946313434
diff --git a/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java b/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
index d1e3b06..04fe7d6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
@@ -78,17 +78,13 @@
   private final SchemaFactory<ReviewDb> schemaFactory;
   private final AccountCache accountCache;
   private final AccountControl.Factory accountControlFactory;
-  private final IdentifiedUser.GenericFactory userFactory;
-
   @Inject
   SingleUserGroup(SchemaFactory<ReviewDb> schemaFactory,
       AccountCache accountCache,
-      AccountControl.Factory accountControlFactory,
-      IdentifiedUser.GenericFactory userFactory) {
+      AccountControl.Factory accountControlFactory) {
     this.schemaFactory = schemaFactory;
     this.accountCache = accountCache;
     this.accountControlFactory = accountControlFactory;
-    this.userFactory = userFactory;
   }
 
   @Override
@@ -170,7 +166,7 @@
         if (name.matches(ACCOUNT_ID_PATTERN)) {
           Account.Id id = new Account.Id(Integer.parseInt(name));
           if (db.accounts().get(id) != null) {
-            add(matches, ids, ctl, project, id);
+            add(matches, ids, ctl, id);
             return matches;
           }
         }
@@ -183,7 +179,7 @@
             if (!e.getSchemeRest().startsWith(a)) {
               break;
             }
-            add(matches, ids, ctl, project, e.getAccountId());
+            add(matches, ids, ctl, e.getAccountId());
           }
         }
 
@@ -191,14 +187,14 @@
           if (!p.getFullName().startsWith(a)) {
             break;
           }
-          add(matches, ids, ctl, project, p.getId());
+          add(matches, ids, ctl, p.getId());
         }
 
         for (Account p : db.accounts().suggestByPreferredEmail(a, b, MAX)) {
           if (!p.getPreferredEmail().startsWith(a)) {
             break;
           }
-          add(matches, ids, ctl, project, p.getId());
+          add(matches, ids, ctl, p.getId());
         }
 
         for (AccountExternalId e : db.accountExternalIds()
@@ -206,7 +202,7 @@
           if (!e.getEmailAddress().startsWith(a)) {
             break;
           }
-          add(matches, ids, ctl, project, e.getAccountId());
+          add(matches, ids, ctl, e.getAccountId());
         }
 
         return matches;
@@ -223,13 +219,13 @@
   }
 
   private void add(List<GroupReference> matches, Set<Account.Id> ids,
-      AccountControl ctl, @Nullable ProjectControl project, Account.Id id) {
+      AccountControl ctl, Account.Id id) {
     if (!ids.add(id) || !ctl.canSee(id)) {
       return;
     }
 
     AccountState state = accountCache.get(id);
-    if (state == null || !isVisible(project, id)) {
+    if (state == null) {
       return;
     }
 
@@ -242,11 +238,6 @@
     matches.add(new GroupReference(uuid, nameOf(uuid, state)));
   }
 
-  private boolean isVisible(@Nullable ProjectControl project, Account.Id id) {
-    return project == null
-        || project.forUser(userFactory.create(id)).isVisible();
-  }
-
   private static String username(AccountGroup.UUID uuid) {
     checkUUID(uuid);
     return uuid.get().substring(UUID_PREFIX.length());