private static boolean isValidHead(File head) { final String ref = readFirstLine(head); return ref != null && (ref.startsWith("ref: refs/") || ObjectId.isId(ref)); //$NON-NLS-1$ }
private static String findRef(String ref, Repository repo) throws IOException { if (!ObjectId.isId(ref)) { Ref r = repo.exactRef(R_REMOTES + DEFAULT_REMOTE_NAME + "/" + ref); //$NON-NLS-1$ if (r != null) return r.getName(); } return ref; } }
private void expandSingle(RefSpec spec, Set<Ref> matched) throws TransportException { String want = spec.getSource(); if (ObjectId.isId(want)) { want(ObjectId.fromString(want)); return; } Ref src = conn.getRef(want); if (src == null) { throw new TransportException(MessageFormat.format(JGitText.get().remoteDoesNotHaveSpec, want)); } if (matched.add(src)) { want(src, spec); } }
if (ObjectId.isId(line)) { final Ref r = new ObjectIdRef.Unpeeled(loose(avail.get(name)), name, ObjectId.fromString(line));
@Nullable private ObjectId resolveSimple(String revstr) throws IOException { if (ObjectId.isId(revstr)) return ObjectId.fromString(revstr); if (Repository.isValidRefName("x/" + revstr)) { //$NON-NLS-1$ Ref r = getRefDatabase().getRef(revstr); if (r != null) return r.getObjectId(); } if (AbbreviatedObjectId.isId(revstr)) return resolveAbbreviation(revstr); int dashg = revstr.indexOf("-g"); //$NON-NLS-1$ if ((dashg + 5) < revstr.length() && 0 <= dashg && isHex(revstr.charAt(dashg + 2)) && isHex(revstr.charAt(dashg + 3)) && isAllHex(revstr, dashg + 4)) { // Possibly output from git describe? String s = revstr.substring(dashg + 2); if (AbbreviatedObjectId.isId(s)) return resolveAbbreviation(s); } return null; }
if (ObjectId.isId(s)) { final Ref r = new ObjectIdRef.Unpeeled(loose(avail.get(rn)), rn, ObjectId.fromString(s));
r = new SymbolicRef(HEAD, r); refs.put(r.getName(), r); } else if (line != null && ObjectId.isId(line)) { Ref r = new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, HEAD, ObjectId.fromString(line));
JGitText.get().invalidRepositoryStateNoHead); if (ObjectId.isId(fullOldName)) throw new DetachedHeadException();
String previousCheckout = resolveReflogCheckout(-Integer .parseInt(time)); if (ObjectId.isId(previousCheckout)) rev = parseSimple(rw, previousCheckout); else
private static boolean isValidHead(File head) { final String ref = readFirstLine(head); return ref != null && (ref.startsWith("ref: refs/") || ObjectId.isId(ref)); //$NON-NLS-1$ }
private static boolean isValidHead(final File head) { final String ref = readFirstLine(head); return ref != null && (ref.startsWith("ref: refs/") || ObjectId.isId(ref)); //$NON-NLS-1$ }
String url = proj.getUrl(); ObjectId objectId; if (ObjectId.isId(proj.getRevision())) { objectId = ObjectId.fromString(proj.getRevision()); } else {
private static String findRef(String ref, Repository repo) throws IOException { if (!ObjectId.isId(ref)) { Ref r = repo.exactRef(R_REMOTES + DEFAULT_REMOTE_NAME + "/" + ref); //$NON-NLS-1$ if (r != null) return r.getName(); } return ref; } }
private static String findRef(String ref, Repository repo) throws IOException { if (!ObjectId.isId(ref)) { Ref r = repo.exactRef(R_REMOTES + DEFAULT_REMOTE_NAME + "/" + ref); //$NON-NLS-1$ if (r != null) return r.getName(); } return ref; } }
public static String getHeadBranch(Repository repository) throws IOException { ObjectId head = repository.resolve(Constants.HEAD); if (head == null) { return Constants.MASTER; } if (ObjectId.isId(repository.getBranch())) { return null; } return repository.getBranch(); }
private void detachHead() throws IOException { final String head = db.getFullBranch(); final ObjectId id = db.resolve(Constants.HEAD); if (!ObjectId.isId(head) && id != null) { final LockFile lf; lf = new LockFile(new File(db.getDirectory(), Constants.HEAD), db.getFS()); if (!lf.lock()) throw new IOException(MessageFormat.format(CLIText.get().cannotLock, Constants.HEAD)); lf.write(id); if (!lf.commit()) throw new IOException(CLIText.get().cannotDeatchHEAD); } }
private void expandSingle(RefSpec spec, Set<Ref> matched) throws TransportException { String want = spec.getSource(); if (ObjectId.isId(want)) { want(ObjectId.fromString(want)); return; } Ref src = conn.getRef(want); if (src == null) { throw new TransportException(MessageFormat.format(JGitText.get().remoteDoesNotHaveSpec, want)); } if (matched.add(src)) { want(src, spec); } }
@Nullable private ObjectId resolveSimple(final String revstr) throws IOException { if (ObjectId.isId(revstr)) return ObjectId.fromString(revstr); if (Repository.isValidRefName("x/" + revstr)) { //$NON-NLS-1$ Ref r = getRefDatabase().getRef(revstr); if (r != null) return r.getObjectId(); } if (AbbreviatedObjectId.isId(revstr)) return resolveAbbreviation(revstr); int dashg = revstr.indexOf("-g"); //$NON-NLS-1$ if ((dashg + 5) < revstr.length() && 0 <= dashg && isHex(revstr.charAt(dashg + 2)) && isHex(revstr.charAt(dashg + 3)) && isAllHex(revstr, dashg + 4)) { // Possibly output from git describe? String s = revstr.substring(dashg + 2); if (AbbreviatedObjectId.isId(s)) return resolveAbbreviation(s); } return null; }
private void checkoutToSelectedBranch(final Git git) throws IOException, GitAPIException { boolean createBranch = !ObjectId.isId(branch); if (createBranch) { Ref ref = git.getRepository().exactRef(R_HEADS + branch); if (ref != null) { createBranch = false; } } CheckoutCommand checkout = git.checkout().setCreateBranch(createBranch).setName(branch); checkout.call(); if (checkout.getResult().getStatus() == CheckoutResult.Status.ERROR) { throw ServerLogger.ROOT_LOGGER.failedToPullRepository(null, defaultRemoteRepository); } }
private void checkoutToSelectedBranch(final Git git) throws IOException, GitAPIException { boolean createBranch = !ObjectId.isId(branch); if (createBranch) { Ref ref = git.getRepository().exactRef(R_HEADS + branch); if (ref != null) { createBranch = false; } } CheckoutCommand checkout = git.checkout().setCreateBranch(createBranch).setName(branch); checkout.call(); if (checkout.getResult().getStatus() == CheckoutResult.Status.ERROR) { throw ServerLogger.ROOT_LOGGER.failedToPullRepository(null, defaultRemoteRepository); } }