/** * Read a single reference. * <p> * Unlike {@link #getRef}, this method expects an unshortened reference * name and does not search using the standard {@link #SEARCH_PATH}. * * @param name * the unabbreviated name of the reference. * @return the reference (if it exists); else {@code null}. * @throws java.io.IOException * the reference space cannot be accessed. * @since 4.1 */ @Nullable public Ref exactRef(String name) throws IOException { Ref ref = getRef(name); if (ref == null || !name.equals(ref.getName())) { return null; } return ref; }
/** * Search for a ref by (possibly abbreviated) name. * * @param name * the name of the ref to lookup. May be a short-hand form, e.g. * "master" which is is automatically expanded to * "refs/heads/master" if "refs/heads/master" already exists. * @return the Ref with the given name, or {@code null} if it does not exist * @throws java.io.IOException * @since 4.2 */ @Nullable public final Ref findRef(String name) throws IOException { return getRefDatabase().getRef(name); }
/** * Whether the {@code Constants#HEAD} reference needs to be linked to the * new destination name. * * @return true if the {@code Constants#HEAD} reference needs to be linked * to the new destination name. * @throws java.io.IOException * the current value of {@code HEAD} cannot be read. */ protected boolean needToUpdateHEAD() throws IOException { Ref head = source.getRefDatabase().getRef(Constants.HEAD); if (head != null && head.isSymbolic()) { head = head.getTarget(); return head.getName().equals(source.getName()); } return false; } }
@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; }
return Result.LOCK_FAILURE; final Ref old = getRefDatabase().getRef(getName()); if (old != null && old.isSymbolic()) { final Ref dst = old.getTarget(); setOldObjectId(old.getObjectId()); final Ref dst = getRefDatabase().getRef(target); if (dst != null && dst.getObjectId() != null) setNewObjectId(dst.getObjectId());
if (myName.startsWith(Constants.R_HEADS) && !getRepository().isBare()) { Ref head = getRefDatabase().getRef(Constants.HEAD); while (head != null && head.isSymbolic()) { head = head.getTarget();
transferConfig.hasDefaultRefFilter()) { return db.getRefDatabase().getRef(name);
public static Ref getBranch(final Git git, final String name) { try { return git.getRepository().getRefDatabase().getRef("refs/heads/" + name); } catch (java.io.IOException e) { } return null; }
public static Ref getBranch( final Git git, final String name ) { try { return git.getRepository().getRefDatabase().getRef( name ); } catch ( java.io.IOException e ) { } return null; }
/** * Read a single reference. * <p> * Unlike {@link #getRef}, this method expects an unshortened reference * name and does not search using the standard {@link #SEARCH_PATH}. * * @param name * the unabbreviated name of the reference. * @return the reference (if it exists); else {@code null}. * @throws IOException * the reference space cannot be accessed. * @since 4.1 */ @Nullable public Ref exactRef(String name) throws IOException { Ref ref = getRef(name); if (ref == null || !name.equals(ref.getName())) { return null; } return ref; }
/** * Search for a ref by (possibly abbreviated) name. * * @param name * the name of the ref to lookup. May be a short-hand form, e.g. * "master" which is is automatically expanded to * "refs/heads/master" if "refs/heads/master" already exists. * @return the Ref with the given name, or {@code null} if it does not exist * @throws java.io.IOException * @since 4.2 */ @Nullable public final Ref findRef(String name) throws IOException { return getRefDatabase().getRef(name); }
/** * Read a single reference. * <p> * Unlike {@link #getRef}, this method expects an unshortened reference * name and does not search using the standard {@link #SEARCH_PATH}. * * @param name * the unabbreviated name of the reference. * @return the reference (if it exists); else {@code null}. * @throws java.io.IOException * the reference space cannot be accessed. * @since 4.1 */ @Nullable public Ref exactRef(String name) throws IOException { Ref ref = getRef(name); if (ref == null || !name.equals(ref.getName())) { return null; } return ref; }
/** * Search for a ref by (possibly abbreviated) name. * * @param name * the name of the ref to lookup. May be a short-hand form, e.g. * "master" which is is automatically expanded to * "refs/heads/master" if "refs/heads/master" already exists. * @return the Ref with the given name, or {@code null} if it does not exist * @throws IOException * @since 4.2 */ @Nullable public Ref findRef(String name) throws IOException { return getRefDatabase().getRef(name); }
public Version call(Git git, GitContext context) throws Exception { String revision = git.getRepository().getRefDatabase().getRef(versionId).getObjectId().getName(); return loadVersion(git, context, versionId, revision); } };
private static RevCommit getLastCommit(Git git, String branch, String path) { RevCommit profileRef = null; try { Ref versionRef = git.getRepository().getRefDatabase().getRef(branch); if (versionRef != null) { String revision = versionRef.getObjectId().getName(); // need to force unix style on windows if (path != null) { path = path.replace(File.separatorChar, '/'); } profileRef = CommitUtils.getLastCommit(git.getRepository(), revision, path != null ? path : "."); } } catch (IOException ex) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Failed to get the last commit for " + path + " on branch " + branch, ex); } } return profileRef; }
public Version call(Git git, GitContext context) throws Exception { String revision = git.getRepository().getRefDatabase().getRef(versionId).getObjectId().getName(); return loadVersion(git, context, versionId, revision); } };
/** * @return true if the {@code Constants#HEAD} reference needs to be linked * to the new destination name. * @throws IOException * the current value of {@code HEAD} cannot be read. */ protected boolean needToUpdateHEAD() throws IOException { Ref head = source.getRefDatabase().getRef(Constants.HEAD); if (head != null && head.isSymbolic()) { head = head.getTarget(); return head.getName().equals(source.getName()); } return false; } }
/** * Whether the {@code Constants#HEAD} reference needs to be linked to the * new destination name. * * @return true if the {@code Constants#HEAD} reference needs to be linked * to the new destination name. * @throws java.io.IOException * the current value of {@code HEAD} cannot be read. */ protected boolean needToUpdateHEAD() throws IOException { Ref head = source.getRefDatabase().getRef(Constants.HEAD); if (head != null && head.isSymbolic()) { head = head.getTarget(); return head.getName().equals(source.getName()); } return false; } }
@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; }
public Ref execute() { try { final Ref value = repo.getRefDatabase().getRef(name); if (value != null) { return value; } final ObjectId treeRef = repo.resolve(name + "^{tree}"); if (treeRef != null) { final ObjectLoader loader = repo.getObjectDatabase().newReader().open(treeRef); if (loader.getType() == OBJ_TREE) { return new ObjectIdRef.PeeledTag(Ref.Storage.NEW, name, ObjectId.fromString(name), treeRef); } } } catch (final Exception ignored) { } return null; } }