Package org.eclipse.jgit.lib
Class RepositoryCache.FileKey
- java.lang.Object
-
- org.eclipse.jgit.lib.RepositoryCache.FileKey
-
- All Implemented Interfaces:
RepositoryCache.Key
- Enclosing class:
- RepositoryCache
public static class RepositoryCache.FileKey extends java.lang.Object implements RepositoryCache.Key
Location of a Repository, using the standard java.io.File API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.io.Filecanonical(java.io.File path)booleanequals(java.lang.Object o)static RepositoryCache.FileKeyexact(java.io.File directory, FS fs)Obtain a pointer to an exact location on disk.java.io.FilegetFile()inthashCode()static booleanisGitRepository(java.io.File dir, FS fs)Guess if a directory contains a Git repository.private static booleanisValidHead(java.io.File head)static RepositoryCache.FileKeylenient(java.io.File directory, FS fs)Obtain a pointer to a location on disk.Repositoryopen(boolean mustExist)Called byRepositoryCache.open(Key)if it doesn't exist yet.private static java.lang.StringreadFirstLine(java.io.File head)static java.io.Fileresolve(java.io.File directory, FS fs)Guess the proper path for a Git repository.java.lang.StringtoString()
-
-
-
Field Detail
-
path
private final java.io.File path
-
fs
private final FS fs
-
-
Constructor Detail
-
FileKey
protected FileKey(java.io.File directory, FS fs)- Parameters:
directory- exact location of the repository.fs- the file system abstraction which will be necessary to perform certain file system operations.
-
-
Method Detail
-
exact
public static RepositoryCache.FileKey exact(java.io.File directory, FS fs)
Obtain a pointer to an exact location on disk.No guessing is performed, the given location is exactly the GIT_DIR directory of the repository.
- Parameters:
directory- location where the repository database is.fs- the file system abstraction which will be necessary to perform certain file system operations.- Returns:
- a key for the given directory.
- See Also:
lenient(File, FS)
-
lenient
public static RepositoryCache.FileKey lenient(java.io.File directory, FS fs)
Obtain a pointer to a location on disk.The method performs some basic guessing to locate the repository. Searched paths are:
directory// assume exact matchdirectory+ "/.git" // assume working directorydirectory+ ".git" // assume bare
- Parameters:
directory- location where the repository database might be.fs- the file system abstraction which will be necessary to perform certain file system operations.- Returns:
- a key for the given directory.
- See Also:
exact(File, FS)
-
canonical
private static java.io.File canonical(java.io.File path)
-
getFile
public final java.io.File getFile()
- Returns:
- location supplied to the constructor.
-
open
public Repository open(boolean mustExist) throws java.io.IOException
Description copied from interface:RepositoryCache.KeyCalled byRepositoryCache.open(Key)if it doesn't exist yet.If a repository does not exist yet in the cache, the cache will call this method to acquire a handle to it.
- Specified by:
openin interfaceRepositoryCache.Key- Parameters:
mustExist- true if the repository must exist in order to be opened; false if a new non-existent repository is permitted to be created (the caller is responsible for calling create).- Returns:
- the new repository instance.
- Throws:
java.io.IOException- the repository could not be read (likely its core.version property is not supported).RepositoryNotFoundException- There is no repository at the given location, only thrown ifmustExistis true.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isGitRepository
public static boolean isGitRepository(java.io.File dir, FS fs)Guess if a directory contains a Git repository.This method guesses by looking for the existence of some key files and directories.
- Parameters:
dir- the location of the directory to examine.fs- the file system abstraction which will be necessary to perform certain file system operations.- Returns:
- true if the directory "looks like" a Git repository; false if it doesn't look enough like a Git directory to really be a Git directory.
-
isValidHead
private static boolean isValidHead(java.io.File head)
-
readFirstLine
private static java.lang.String readFirstLine(java.io.File head)
-
resolve
public static java.io.File resolve(java.io.File directory, FS fs)Guess the proper path for a Git repository.The method performs some basic guessing to locate the repository. Searched paths are:
directory// assume exact matchdirectory+ "/.git" // assume working directorydirectory+ ".git" // assume bare
- Parameters:
directory- location to guess from. Several permutations are tried.fs- the file system abstraction which will be necessary to perform certain file system operations.- Returns:
- the actual directory location if a better match is found; null if there is no suitable match.
-
-