public void updateChoices(boolean reportError, Form<?> form) {
   final String repoUriStr = repositoryUriModel.getObject();
   if (REPOSITORY.sample != null && REPOSITORY.sample.equals(repoUriStr)) {
     return;
   }
   List<String> branchNames = new ArrayList<>();
   if (repoUriStr != null) {
     try {
       RepositoryManager manager = this.manager.get();
       URI repoURI = new URI(repoUriStr);
       RepositoryResolver resolver = RepositoryResolver.lookup(repoURI);
       String repoName = resolver.getName(repoURI);
       RepositoryInfo repoInfo = manager.getByRepoName(repoName);
       String repoId = repoInfo.getId();
       List<Ref> branchRefs = manager.listBranches(repoId);
       for (Ref branch : branchRefs) {
         branchNames.add(branch.localName());
       }
     } catch (IOException | URISyntaxException e) {
       if (reportError) {
         form.error("Could not list branches: " + e.getMessage());
       }
       branchNames = new ArrayList<String>();
     }
     String current = (String) choice.getModelObject();
     if (current != null && !branchNames.contains(current)) {
       branchNames.add(0, current);
     }
   }
   choice.setChoices(branchNames);
 }