Example usage for org.eclipse.jgit.lib RefUpdate disableRefLog

List of usage examples for org.eclipse.jgit.lib RefUpdate disableRefLog

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib RefUpdate disableRefLog.

Prototype

public void disableRefLog() 

Source Link

Document

Don't record this update in the ref's associated reflog.

Usage

From source file:org.eclipse.egit.core.op.CloneOperation.java

License:Open Source License

private void doInit(final IProgressMonitor monitor) throws URISyntaxException, IOException {
    monitor.setTaskName(CoreText.CloneOperation_initializingRepository);

    local = new FileRepository(gitdir);
    local.create();/* w w w . j  a v a  2 s .  c  o m*/

    final RefUpdate head = local.updateRef(Constants.HEAD);
    head.disableRefLog();
    head.link(branch);

    remoteConfig = new RemoteConfig(local.getConfig(), remoteName);
    remoteConfig.addURI(uri);

    final String dst = Constants.R_REMOTES + remoteConfig.getName();
    RefSpec wcrs = new RefSpec();
    wcrs = wcrs.setForceUpdate(true);
    wcrs = wcrs.setSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$

    if (allSelected) {
        remoteConfig.addFetchRefSpec(wcrs);
    } else {
        for (final Ref ref : selectedBranches)
            if (wcrs.matchSource(ref))
                remoteConfig.addFetchRefSpec(wcrs.expandFromSource(ref));
    }

    // we're setting up for a clone with a checkout
    local.getConfig().setBoolean("core", null, "bare", false); //$NON-NLS-1$ //$NON-NLS-2$

    remoteConfig.update(local.getConfig());

    // branch is like 'Constants.R_HEADS + branchName', we need only
    // the 'branchName' part
    String branchName = branch.substring(Constants.R_HEADS.length());

    // setup the default remote branch for branchName
    local.getConfig().setString("branch", branchName, "remote", remoteName); //$NON-NLS-1$ //$NON-NLS-2$
    local.getConfig().setString("branch", branchName, "merge", branch); //$NON-NLS-1$ //$NON-NLS-2$

    local.getConfig().save();
}

From source file:org.jboss.forge.git.Clone.java

License:Eclipse Distribution License

private void doCheckout(final Ref branch) throws IOException {
    if (branch == null)
        throw new Die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote);
    if (!Constants.HEAD.equals(branch.getName())) {
        RefUpdate u = db.updateRef(Constants.HEAD);
        u.disableRefLog();
        u.link(branch.getName());/*w  ww .  j a va  2s  .  c om*/
    }

    final RevCommit commit = parseCommit(branch);
    final RefUpdate u = db.updateRef(Constants.HEAD);
    u.setNewObjectId(commit);
    u.forceUpdate();

    DirCache dc = db.lockDirCache();
    DirCacheCheckout co = new DirCacheCheckout(db, dc, commit.getTree());
    co.checkout();
}

From source file:org.webcat.core.git.GitCloner.java

License:Open Source License

private void doCheckout(Repository repository, Ref branch) throws IOException {
    if (!Constants.HEAD.equals(branch.getName())) {
        RefUpdate refUpdate = repository.updateRef(Constants.HEAD);
        refUpdate.disableRefLog();
        refUpdate.link(branch.getName());
    }/* w  w  w  .ja va2 s.  co  m*/

    RevCommit commit = parseCommit(repository, branch);
    RefUpdate refUpdate = repository.updateRef(Constants.HEAD);
    refUpdate.setNewObjectId(commit);
    refUpdate.forceUpdate();

    DirCache dirCache = repository.lockDirCache();
    DirCacheCheckout checkout = new DirCacheCheckout(repository, dirCache, commit.getTree());
    checkout.checkout();
}