private void deleteAllRefs() throws Exception {
   final RevWalk rw = new RevWalk(db);
   for (final Ref r : db.getAllRefs().values()) {
     if (Constants.HEAD.equals(r.getName())) continue;
     final RefUpdate u = db.updateRef(r.getName());
     u.setForceUpdate(true);
     u.delete(rw);
   }
 }
Example #2
0
  private void doCheckout(final Ref branch) throws IOException {
    if (branch == null) throw die("cannot checkout; no HEAD advertised by remote");
    if (!Constants.HEAD.equals(branch.getName())) db.writeSymref(Constants.HEAD, branch.getName());

    final Commit commit = db.mapCommit(branch.getObjectId());
    final RefUpdate u = db.updateRef(Constants.HEAD);
    u.setNewObjectId(commit.getCommitId());
    u.forceUpdate();

    final GitIndex index = new GitIndex(db);
    final Tree tree = commit.getTree();
    final WorkDirCheckout co;

    co = new WorkDirCheckout(db, db.getWorkDir(), index, tree);
    co.checkout();
    index.write();
  }
Example #3
0
 private void updateHead(final Commit commit) throws IOException {
   final RefUpdate refUpdate = repository.updateRef(branchName);
   refUpdate.setNewObjectId(commit.getCommitId());
   refUpdate.setRefLogMessage(commit.getMessage(), false);
   refUpdate.forceUpdate();
   final RefUpdate refUpdate2 = repository.updateRef(Constants.HEAD);
   refUpdate2.setNewObjectId(commit.getCommitId());
   refUpdate2.setRefLogMessage(commit.getMessage(), false);
   refUpdate2.forceUpdate();
 }