* must be provided if warn = true
* @return repository for current project, or null
*/
private static Repository getRepository(boolean warn,
IStructuredSelection selection, Shell shell) {
RepositoryMapping mapping = null;
IPath[] locations = getSelectedLocations(selection);
if (GitTraceLocation.SELECTION.isActive())
GitTraceLocation.getTrace().trace(
GitTraceLocation.SELECTION.getLocation(), "selection=" //$NON-NLS-1$
+ selection + ", locations=" //$NON-NLS-1$
+ Arrays.toString(locations));
for (IPath location : locations) {
RepositoryMapping repositoryMapping = RepositoryMapping
.getMapping(location);
if (mapping == null)
mapping = repositoryMapping;
if (repositoryMapping == null)
return null;
if (mapping.getRepository() != repositoryMapping.getRepository()) {
if (warn)
MessageDialog.openError(shell,
UIText.RepositoryAction_multiRepoSelectionTitle,
UIText.RepositoryAction_multiRepoSelection);
return null;