- java.lang.Object
-
- org.eclipse.jgit.lib.RepositoryCache.FileKey
-
- All Implemented Interfaces:
RepositoryCache.Key
- Enclosing class:
- RepositoryCache
public static class RepositoryCache.FileKey extends 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 booleanequals(Object o)static RepositoryCache.FileKeyexact(File directory, FS fs)Obtain a pointer to an exact location on disk.FilegetFile()inthashCode()static booleanisGitRepository(File dir, FS fs)Guess if a directory contains a Git repository.static RepositoryCache.FileKeylenient(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.static Fileresolve(File directory, FS fs)Guess the proper path for a Git repository.StringtoString()
-
-
-
Method Detail
-
exact
public static RepositoryCache.FileKey exact(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(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)
-
getFile
public final File getFile()
- Returns:
- location supplied to the constructor.
-
open
public Repository open(boolean mustExist) throws 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:
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.
-
isGitRepository
public static boolean isGitRepository(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.
-
resolve
public static File resolve(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.
-
-