indexSignatureIsInvalid=Index signature is invalid: {0}
indexWriteException=Modified index could not be written
initFailedBareRepoDifferentDirs=When initializing a bare repo with directory {0} and separate git-dir {1} specified both folders must point to the same location
+initFailedDirIsNoDirectory=Cannot set directory to ''{0}'' which is not a directory
+initFailedGitDirIsNoDirectory=Cannot set git-dir to ''{0}'' which is not a directory
initFailedNonBareRepoSameDirs=When initializing a non-bare repo with directory {0} and separate git-dir {1} specified both folders should not point to the same location
inMemoryBufferLimitExceeded=In-memory buffer limit exceeded
inputDidntMatchLength=Input did not match supplied length. {0} bytes are missing.
command.setBare(bare);
if (directory == null && gitDir == null)
directory = new File(u.getHumanishName(), Constants.DOT_GIT);
+ validateDirs(directory, gitDir, bare);
if (directory != null && directory.exists()
&& directory.listFiles().length != 0)
throw new JGitInternalException(MessageFormat.format(
private static void validateDirs(File directory, File gitDir, boolean bare)
throws IllegalStateException {
if (directory != null) {
+ if (directory.exists() && !directory.isDirectory()) {
+ throw new IllegalStateException(MessageFormat.format(
+ JGitText.get().initFailedDirIsNoDirectory, directory));
+ }
+ if (gitDir != null && gitDir.exists() && !gitDir.isDirectory()) {
+ throw new IllegalStateException(MessageFormat.format(
+ JGitText.get().initFailedGitDirIsNoDirectory,
+ gitDir));
+ }
if (bare) {
if (gitDir != null && !gitDir.equals(directory))
throw new IllegalStateException(MessageFormat.format(
/***/ public String indexSignatureIsInvalid;
/***/ public String indexWriteException;
/***/ public String initFailedBareRepoDifferentDirs;
+ /***/ public String initFailedDirIsNoDirectory;
+ /***/ public String initFailedGitDirIsNoDirectory;
/***/ public String initFailedNonBareRepoSameDirs;
/***/ public String inMemoryBufferLimitExceeded;
/***/ public String inputDidntMatchLength;