List of usage examples for org.eclipse.jgit.lib Constants HEAD
String HEAD
To view the source code for org.eclipse.jgit.lib Constants HEAD.
Click Source Link
From source file:org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { switch (buttonId) { case IDialogConstants.PROCEED_ID: CommitUI commitUI = new CommitUI(getShell(), repository, new IResource[0], true); shouldContinue = commitUI.commit(); break;// w w w .ja v a 2 s.co m case IDialogConstants.ABORT_ID: final ResetOperation operation = new ResetOperation(repository, Constants.HEAD, ResetType.HARD); String jobname = NLS.bind(UIText.ResetAction_reset, Constants.HEAD); JobUtil.scheduleUserWorkspaceJob(operation, jobname, JobFamilies.RESET); shouldContinue = true; break; case IDialogConstants.SKIP_ID: StashCreateUI stashCreateUI = new StashCreateUI(repository); shouldContinue = stashCreateUI.createStash(getShell()); break; case IDialogConstants.CANCEL_ID: default: break; } super.buttonPressed(buttonId); }
From source file:org.eclipse.egit.ui.internal.clone.SourceBranchPage.java
License:Open Source License
private void revalidateImpl(final RepositorySelection newRepoSelection) { if (label.isDisposed() || !isCurrentPage()) return;/*from w w w .ja v a2s . c om*/ final ListRemoteOperation listRemoteOp; try { final URIish uri = newRepoSelection.getURI(); final Repository db = new FileRepository(new File("/tmp")); //$NON-NLS-1$ int timeout = Activator.getDefault().getPreferenceStore() .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT); listRemoteOp = new ListRemoteOperation(db, uri, timeout); if (credentials != null) listRemoteOp.setCredentialsProvider( new UsernamePasswordCredentialsProvider(credentials.getUser(), credentials.getPassword())); getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { listRemoteOp.run(monitor); } }); } catch (InvocationTargetException e) { Throwable why = e.getCause(); transportError(why.getMessage()); ErrorDialog.openError(getShell(), UIText.SourceBranchPage_transportError, UIText.SourceBranchPage_cannotListBranches, new Status(IStatus.ERROR, Activator.getPluginId(), 0, why.getMessage(), why.getCause())); return; } catch (IOException e) { transportError(UIText.SourceBranchPage_cannotCreateTemp); return; } catch (InterruptedException e) { transportError(UIText.SourceBranchPage_remoteListingCancelled); return; } final Ref idHEAD = listRemoteOp.getRemoteRef(Constants.HEAD); head = null; for (final Ref r : listRemoteOp.getRemoteRefs()) { final String n = r.getName(); if (!n.startsWith(Constants.R_HEADS)) continue; availableRefs.add(r); if (idHEAD == null || head != null) continue; if (r.getObjectId().equals(idHEAD.getObjectId())) head = r; } Collections.sort(availableRefs, new Comparator<Ref>() { public int compare(final Ref o1, final Ref o2) { return o1.getName().compareTo(o2.getName()); } }); if (idHEAD != null && head == null) { head = idHEAD; availableRefs.add(0, idHEAD); } validatedRepoSelection = newRepoSelection; refsViewer.setInput(availableRefs); refsViewer.setAllChecked(true); checkPage(); checkForEmptyRepo(); }
From source file:org.eclipse.egit.ui.internal.commands.shared.RebaseCurrentRefCommand.java
License:Open Source License
private static boolean hasHead(Repository repo) { try {/*from w w w. j a v a2s .c om*/ Ref headRef = repo.getRef(Constants.HEAD); return headRef != null && headRef.getObjectId() != null; } catch (IOException e) { return false; } }
From source file:org.eclipse.egit.ui.internal.commit.CommitHelper.java
License:Open Source License
private static RevCommit getHeadCommit(Repository repository) { RevCommit headCommit = null;// www. java2 s.co m try { ObjectId parentId = repository.resolve(Constants.HEAD); if (parentId != null) headCommit = new RevWalk(repository).parseCommit(parentId); } catch (IOException e) { Activator.handleError(UIText.CommitAction_errorRetrievingCommit, e, true); } return headCommit; }
From source file:org.eclipse.egit.ui.internal.commit.CommitSelectionDialog.java
License:Open Source License
/** * Create commit selection dialog//from w ww .j a va2 s. c om * * @param shell * @param multi */ public CommitSelectionDialog(Shell shell, boolean multi) { super(shell, multi); setTitle(UIText.CommitSelectionDialog_Title); setMessage(UIText.CommitSelectionDialog_Message); labelProvider = new CommitLabelProvider(); setListLabelProvider(labelProvider); setDetailsLabelProvider(new GitLabelProvider() { @Override public Image getImage(Object element) { if (element instanceof RepositoryCommit) { RepositoryCommit commit = (RepositoryCommit) element; return super.getImage(commit.getRepository()); } return super.getImage(element); } @Override public String getText(Object element) { if (element instanceof RepositoryCommit) { RepositoryCommit commit = (RepositoryCommit) element; return super.getText(commit.getRepository()); } return super.getText(element); } }); setInitialPattern(Constants.HEAD, FULL_SELECTION); }
From source file:org.eclipse.egit.ui.internal.commit.CommitUI.java
License:Open Source License
private void buildIndexHeadDiffList(IProject[] selectedProjects, IProgressMonitor monitor) throws IOException, OperationCanceledException { monitor.beginTask(UIText.CommitActionHandler_calculatingChanges, 1000); EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor); CountingVisitor counter = new CountingVisitor(); for (IProject p : selectedProjects) { try {//from w ww. j a v a 2s. co m p.accept(counter); } catch (CoreException e) { // ignore } } WorkingTreeIterator it = IteratorService.createInitialIterator(repo); if (it == null) throw new OperationCanceledException(); // workspace is closed indexDiff = new IndexDiff(repo, Constants.HEAD, it); indexDiff.diff(jgitMonitor, counter.count, 0, NLS.bind(UIText.CommitActionHandler_repository, repo.getDirectory().getPath())); includeList(indexDiff.getAdded(), indexChanges); includeList(indexDiff.getChanged(), indexChanges); includeList(indexDiff.getRemoved(), indexChanges); includeList(indexDiff.getMissing(), notIndexed); includeList(indexDiff.getModified(), notIndexed); includeList(indexDiff.getUntracked(), notTracked); if (monitor.isCanceled()) throw new OperationCanceledException(); monitor.done(); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private static List<RefContentProposal> createProposalsFilteredRemote( final List<RefContentProposal> proposals) { final List<RefContentProposal> result = new ArrayList<RefContentProposal>(); for (final RefContentProposal p : proposals) { final String content = p.getContent(); if (content.equals(Constants.HEAD) || content.startsWith(Constants.R_HEADS)) result.add(p);/*from w ww .ja v a 2 s . c om*/ } return result; }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
/** * Set information needed for assisting user with entering data and * validating user input. This method automatically enables the panel. * * @param localRepo// ww w . j a v a2s . c om * local repository where specifications will be applied. * @param remoteRefs * collection of remote refs as advertised by remote repository. * Typically they are collected by {@link FetchConnection} * implementation. * @param remoteName * optional name for remote configuration, if edited * specification list is related to this remote configuration. * Can be null. When not null, panel is filled with default * fetch/push specifications for this remote configuration. */ public void setAssistanceData(final Repository localRepo, final Collection<Ref> remoteRefs, final String remoteName) { this.localDb = localRepo; this.remoteName = remoteName; final List<RefContentProposal> remoteProposals = createContentProposals(remoteRefs, null); remoteProposalProvider.setProposals(remoteProposals); remoteRefNames = new HashSet<String>(); for (final RefContentProposal p : remoteProposals) remoteRefNames.add(p.getContent()); Ref HEAD = null; try { HEAD = localDb.getRef(Constants.HEAD); } catch (IOException e) { Activator.logError("Couldn't read HEAD from local repository", e); //$NON-NLS-1$ } final List<RefContentProposal> localProposals = createContentProposals(localDb.getAllRefs().values(), HEAD); localProposalProvider.setProposals(localProposals); localRefNames = new HashSet<String>(); for (final RefContentProposal ref : localProposals) localRefNames.add(ref.getContent()); final List<RefContentProposal> localFilteredProposals = createProposalsFilteredLocal(localProposals); final List<RefContentProposal> remoteFilteredProposals = createProposalsFilteredRemote(remoteProposals); if (pushSpecs) { creationSrcComboSupport.setProposals(localFilteredProposals); creationDstComboSupport.setProposals(remoteFilteredProposals); } else { creationSrcComboSupport.setProposals(remoteFilteredProposals); creationDstComboSupport.setProposals(localFilteredProposals); } validateCreationPanel(); if (pushSpecs) { deleteRefComboSupport.setProposals(remoteFilteredProposals); validateDeleteCreationPanel(); } try { if (remoteName == null) predefinedConfigured = Collections.emptyList(); else { final RemoteConfig rc = new RemoteConfig(localDb.getConfig(), remoteName); if (pushSpecs) predefinedConfigured = rc.getPushRefSpecs(); else predefinedConfigured = rc.getFetchRefSpecs(); for (final RefSpec spec : predefinedConfigured) addRefSpec(spec); } } catch (URISyntaxException e) { predefinedConfigured = null; ErrorDialog.openError(panel.getShell(), UIText.RefSpecPanel_errorRemoteConfigTitle, UIText.RefSpecPanel_errorRemoteConfigDescription, new Status(IStatus.ERROR, Activator.getPluginId(), 0, e.getMessage(), e)); } updateAddPredefinedButton(addConfiguredButton, predefinedConfigured); if (pushSpecs) predefinedBranches = Transport.REFSPEC_PUSH_ALL; else { final String r; if (remoteName == null) r = UIText.RefSpecPanel_refChooseRemoteName; else r = remoteName; predefinedBranches = new RefSpec("refs/heads/*:refs/remotes/" //$NON-NLS-1$ + r + "/*"); //$NON-NLS-1$ } updateAddPredefinedButton(addBranchesButton, predefinedBranches); setEnable(true); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private List<RefContentProposal> createProposalsFilteredLocal(final List<RefContentProposal> proposals) { final List<RefContentProposal> result = new ArrayList<RefContentProposal>(); for (final RefContentProposal p : proposals) { final String content = p.getContent(); if (pushSpecs) { if (content.equals(Constants.HEAD) || content.startsWith(Constants.R_HEADS)) result.add(p);/*from ww w . jav a 2 s. co m*/ } else { if (content.startsWith(Constants.R_REMOTES)) result.add(p); } } return result; }
From source file:org.eclipse.egit.ui.internal.decorators.DecoratableResourceAdapter.java
License:Open Source License
@SuppressWarnings("fallthrough") public DecoratableResourceAdapter(IResource resourceToWrap) throws IOException { trace = GitTraceLocation.DECORATION.isActive(); resource = resourceToWrap;// w w w . j a v a 2s . c om long start = 0; if (trace) { GitTraceLocation.getTrace().trace(GitTraceLocation.DECORATION.getLocation(), "Decorate " + resource.getFullPath()); //$NON-NLS-1$ start = System.currentTimeMillis(); } try { mapping = RepositoryMapping.getMapping(resource); repository = mapping.getRepository(); headId = repository.resolve(Constants.HEAD); store = Activator.getDefault().getPreferenceStore(); String repoName = Activator.getDefault().getRepositoryUtil().getRepositoryName(repository); RepositoryState state = repository.getRepositoryState(); if (state != RepositoryState.SAFE) repositoryName = repoName + '|' + state.getDescription(); else repositoryName = repoName; branch = getShortBranch(); TreeWalk treeWalk = createThreeWayTreeWalk(); if (treeWalk == null) return; switch (resource.getType()) { case IResource.FILE: if (!treeWalk.next()) return; extractResourceProperties(treeWalk); break; case IResource.PROJECT: tracked = true; case IResource.FOLDER: extractContainerProperties(treeWalk); break; } } finally { if (trace) GitTraceLocation.getTrace().trace(GitTraceLocation.DECORATION.getLocation(), "Decoration took " + (System.currentTimeMillis() - start) //$NON-NLS-1$ + " ms"); //$NON-NLS-1$ } }