public static class RepositoryCache.FileKey extends Object implements RepositoryCache.Key
Modifier | Constructor and Description |
---|---|
protected |
FileKey(File directory,
FS fs) |
Modifier and Type | Method and 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 by
RepositoryCache.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() |
public static RepositoryCache.FileKey exact(File directory, FS fs)
No guessing is performed, the given location is exactly the GIT_DIR directory of the repository.
directory
- location where the repository database is.fs
- the file system abstraction which will be necessary to
perform certain file system operations.lenient(File, FS)
public static RepositoryCache.FileKey lenient(File directory, FS fs)
The method performs some basic guessing to locate the repository. Searched paths are:
directory
// assume exact matchdirectory
+ "/.git" // assume working directorydirectory
+ ".git" // assume baredirectory
- location where the repository database might be.fs
- the file system abstraction which will be necessary to
perform certain file system operations.exact(File, FS)
public final File getFile()
public Repository open(boolean mustExist) throws IOException
RepositoryCache.Key
RepositoryCache.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.
open
in interface RepositoryCache.Key
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).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
if mustExist
is true.public static boolean isGitRepository(File dir, FS fs)
This method guesses by looking for the existence of some key files and directories.
dir
- the location of the directory to examine.fs
- the file system abstraction which will be necessary to
perform certain file system operations.public static File resolve(File directory, FS fs)
The method performs some basic guessing to locate the repository. Searched paths are:
directory
// assume exact matchdirectory
+ "/.git" // assume working directorydirectory
+ ".git" // assume baredirectory
- location to guess from. Several permutations are tried.fs
- the file system abstraction which will be necessary to
perform certain file system operations.Copyright © 2019 Eclipse JGit Project. All rights reserved.