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 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 boolean
equals(Object o)
static RepositoryCache.FileKey
exact(File directory, FS fs)
Obtain a pointer to an exact location on disk.File
getFile()
int
hashCode()
static boolean
isGitRepository(File dir, FS fs)
Guess if a directory contains a Git repository.static RepositoryCache.FileKey
lenient(File directory, FS fs)
Obtain a pointer to a location on disk.Repository
open(boolean mustExist)
Called byRepositoryCache.open(Key)
if it doesn't exist yet.static File
resolve(File directory, FS fs)
Guess the proper path for a Git repository.String
toString()
-
-
-
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.Key
Called 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:
open
in 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 ifmustExist
is 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.
-
-