/** {@inheritDoc} */ @Override public void create(boolean bare) throws IOException { if (exists()) throw new IOException(MessageFormat.format( JGitText.get().repositoryAlreadyExists, "")); //$NON-NLS-1$ String master = Constants.R_HEADS + Constants.MASTER; RefUpdate.Result result = updateRef(Constants.HEAD, true).link(master); if (result != RefUpdate.Result.NEW) throw new IOException(result.name()); }
private boolean linkHEAD(RefUpdate target) { try { RefUpdate u = refdb.newUpdate(Constants.HEAD, false); u.disableRefLog(); switch (u.link(target.getName())) { case NEW: case FORCED: case NO_CHANGE: return true; default: return false; } } catch (IOException e) { return false; } } }
rup.setRefLogMessage("rebase finished: returning to " + headName, //$NON-NLS-1$ false); res = rup.link(headName); switch (res) { case FAST_FORWARD:
if (orphan) { if (startPoint == null && startCommit == null) { Result r = repo.updateRef(Constants.HEAD).link( getBranchName()); if (!EnumSet.of(Result.NEW, Result.FORCED).contains(r)) Result updateResult; if (ref != null) updateResult = refUpdate.link(ref.getName()); else if (orphan) { updateResult = refUpdate.link(getBranchName()); ref = repo.exactRef(Constants.HEAD); } else {
head.link(Constants.R_HEADS + Constants.MASTER);
final RefUpdate newHead = clonedRepo.updateRef(Constants.HEAD); newHead.disableRefLog(); newHead.link(head.getName()); addMergeConfig(clonedRepo, head);
public static void linkRef(RefUpdate refUpdate, String target) { try { RefUpdate.Result result = refUpdate.link(target); if (result != RefUpdate.Result.FORCED && result != RefUpdate.Result.NEW && result != RefUpdate.Result.NO_CHANGE) throw new RefUpdateException(result); } catch (IOException e) { throw new RuntimeException(e); } }
if (headName.startsWith(Constants.R_REFS)) { res = refUpdate.link(headName); } else { refUpdate.setNewObjectId(repo.readOrigHead());
Result updateHead( Repository repo, String newHead, boolean force, boolean detach ) throws IOException { RefUpdate refUpdate = repo.getRefDatabase().newUpdate(Constants.HEAD, detach); refUpdate.setForceUpdate(force); return refUpdate.link(newHead); }
public static void attachRepositoryHead(@Nonnull Repository repo, @Nonnull String refName) throws IOException { RefUpdate update = prepareUpdateHead(repo, Repository.shortenRefName(refName), false); RefUpdateValidator.validate(update.link(refName)); }
@Override public void create(boolean bare) throws IOException { if (exists()) throw new IOException(MessageFormat.format( JGitText.get().repositoryAlreadyExists, "")); //$NON-NLS-1$ String master = Constants.R_HEADS + Constants.MASTER; RefUpdate.Result result = updateRef(Constants.HEAD, true).link(master); if (result != RefUpdate.Result.NEW) throw new IOException(result.name()); }
/** {@inheritDoc} */ @Override public void create(boolean bare) throws IOException { if (exists()) throw new IOException(MessageFormat.format( JGitText.get().repositoryAlreadyExists, "")); //$NON-NLS-1$ String master = Constants.R_HEADS + Constants.MASTER; RefUpdate.Result result = updateRef(Constants.HEAD, true).link(master); if (result != RefUpdate.Result.NEW) throw new IOException(result.name()); }
public static void attachRepositoryHead(Repository repo, String refName) throws IOException { RefUpdate update = prepareUpdateHead(repo, Repository.shortenRefName(refName), false); RefUpdateValidator.validate(update.link(refName)); }
ru.setRefLogMessage("push", true); //$NON-NLS-1$ if (getNewSymref() != null) { setResult(ru.link(getNewSymref())); } else { ru.setNewObjectId(getNewId());
public static void attachRepositoryHead(Repository repo, String refName) throws IOException { RefUpdate update = prepareUpdateHead(repo, Repository.shortenRefName(refName), false); RefUpdateValidator.validate(update.link(refName)); }
private boolean linkHEAD(RefUpdate target) { try { RefUpdate u = refdb.newUpdate(Constants.HEAD, false); u.disableRefLog(); switch (u.link(target.getName())) { case NEW: case FORCED: case NO_CHANGE: return true; default: return false; } } catch (IOException e) { return false; } } }
private boolean linkHEAD(RefUpdate target) { try { RefUpdate u = refdb.newUpdate(Constants.HEAD, false); u.disableRefLog(); switch (u.link(target.getName())) { case NEW: case FORCED: case NO_CHANGE: return true; default: return false; } } catch (IOException e) { return false; } } }
private void doCheckout(final Ref branch) throws IOException { if (branch == null) throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote); if (!Constants.HEAD.equals(branch.getName())) { RefUpdate u = db.updateRef(Constants.HEAD); u.disableRefLog(); u.link(branch.getName()); } 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(); }
protected void checkoutBranch(String branchName) throws IllegalStateException, IOException { try (RevWalk walk = new RevWalk(db)) { RevCommit head = walk.parseCommit(db.resolve(Constants.HEAD)); RevCommit branch = walk.parseCommit(db.resolve(branchName)); DirCacheCheckout dco = new DirCacheCheckout(db, head.getTree().getId(), db.lockDirCache(), branch.getTree().getId()); dco.setFailOnConflict(true); dco.checkout(); } // update the HEAD RefUpdate refUpdate = db.updateRef(Constants.HEAD); refUpdate.setRefLogMessage("checkout: moving to " + branchName, false); refUpdate.link(branchName); }
protected void checkoutBranch(String branchName) throws IllegalStateException, IOException { RevWalk walk = new RevWalk(db); RevCommit head = walk.parseCommit(db.resolve(Constants.HEAD)); RevCommit branch = walk.parseCommit(db.resolve(branchName)); DirCacheCheckout dco = new DirCacheCheckout(db, head.getTree().getId(), db.lockDirCache(), branch.getTree().getId()); dco.setFailOnConflict(true); dco.checkout(); walk.release(); // update the HEAD RefUpdate refUpdate = db.updateRef(Constants.HEAD); refUpdate.setRefLogMessage("checkout: moving to " + branchName, false); refUpdate.link(branchName); }