private boolean checkTrackedBranchesConfigured(){
  LOG.info("checking tracked branch configuration...");
  for (  GitRepository repository : myRepositories) {
    VirtualFile root=repository.getRoot();
    final GitLocalBranch branch=repository.getCurrentBranch();
    if (branch == null) {
      LOG.info("checkTrackedBranchesConfigured: current branch is null in " + repository);
      notifyImportantError(myProject,"Can't update: no current branch","You are in 'detached HEAD' state, which means that you're not on any branch" + rootStringIfNeeded(root) + "Checkout a branch to make update possible.");
      return false;
    }
    GitBranchTrackInfo trackInfo=GitBranchUtil.getTrackInfoForBranch(repository,branch);
    if (trackInfo == null) {
      final String branchName=branch.getName();
      LOG.info(String.format("checkTrackedBranchesConfigured: no track info for current branch %s in %s",branch,repository));
      notifyImportantError(myProject,"Can't update: no tracked branch","No tracked branch configured for branch " + code(branchName) + rootStringIfNeeded(root)+ "To make your branch track a remote branch call, for example,<br/>"+ "<code>git branch --set-upstream "+ branchName+ " origin/"+ branchName+ "</code>");
      return false;
    }
    myTrackedBranches.put(root,new GitBranchPair(branch,trackInfo.getRemoteBranch()));
  }
  return true;
}

private boolean checkTrackedBranchesConfigured ( ) { LOG . info ( "checking tracked branch configuration..." ) ; for ( GitRepository repository : myRepositories ) { VirtualFile root = repository . getRoot ( ) ; final GitLocalBranch branch = repository . getCurrentBranch ( ) ; if ( branch == null ) { LOG . info ( "checkTrackedBranchesConfigured: current branch is null in " + repository ) ; notifyImportantError ( myProject , "Can't update: no current branch" , "You are in 'detached HEAD' state, which means that you're not on any branch" + rootStringIfNeeded ( root ) + "Checkout a branch to make update possible." ) ; return false ; } GitBranchTrackInfo trackInfo = GitBranchUtil . getTrackInfoForBranch ( repository , branch ) ; if ( trackInfo == null ) { final String branchName = branch . getName ( ) ; LOG . info ( String . format ( "checkTrackedBranchesConfigured: no track info for current branch %s in %s" , branch , repository ) ) ; notifyImportantError ( myProject , "Can't update: no tracked branch" , "No tracked branch configured for branch " + code ( branchName ) + rootStringIfNeeded ( root ) + "To make your branch track a remote branch call, for example,<br/>" + "<code>git branch --set-upstream " + branchName + " origin/" + branchName + "</code>" ) ; return false ; } myTrackedBranches . put ( root , new GitBranchPair ( branch , trackInfo . getRemoteBranch ( ) ) ) ; } return true ; }
for each root check that the repository is on branch , and this branch is tracking a remote branch , and the remote branch exists . if it is not true for at least one of roots , notify and return false . if branch configuration is ok for all roots , return true .
