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
Location of a Repository, using the standard java.io.File API.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Filebooleanstatic RepositoryCache.FileKeyObtain a pointer to an exact location on disk.final FilegetFile()inthashCode()static booleanisGitRepository(File dir, FS fs) Guess if a directory contains a Git repository.private static booleanisValidHead(File head) static RepositoryCache.FileKeyObtain a pointer to a location on disk.open(boolean mustExist) Called byRepositoryCache.open(Key)if it doesn't exist yet.private static StringreadFirstLine(File head) static FileGuess the proper path for a Git repository.toString()
-
Field Details
-
path
-
fs
-
-
Constructor Details
-
FileKey
- Parameters:
directory- exact location of the repository.fs- the file system abstraction which will be necessary to perform certain file system operations.
-
-
Method Details
-
exact
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
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:
-
canonical
-
getFile
- Returns:
- location supplied to the constructor.
-
open
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.
-
hashCode
public int hashCode() -
equals
-
toString
-
isGitRepository
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
-
readFirstLine
-
resolve
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.
-