[JGIT PATCH 10/19] Test for the config file when creating a new repository
From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:47:06
Subsystem:
the rest · Maintainer:
Linus Torvalds
If the configuration file already exists then we should assume that the repository also exists. Rather than computing the file name we should rely upon the computation done in the constructor, whose result is held in the RepositoryConfig's file property. Signed-off-by: Shawn O. Pearce <redacted> --- .../src/org/spearce/jgit/lib/Repository.java | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 4e987e1..7fb1ef7 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java@@ -171,7 +171,8 @@ public synchronized void create() throws IOException { * in case of IO problem */ public void create(boolean bare) throws IOException { - if ((bare ? new File(gitDir, "config") : gitDir).exists()) { + final RepositoryConfig cfg = getConfig(); + if (cfg.getFile().exists()) { throw new IllegalStateException("Repository already exists: " + gitDir); }
@@ -184,7 +185,6 @@ public void create(boolean bare) throws IOException { final String master = Constants.R_HEADS + Constants.MASTER; refs.link(Constants.HEAD, master); - RepositoryConfig cfg = getConfig(); cfg.create(); if (bare) cfg.setBoolean("core", null, "bare", true);
--
1.6.4.rc2.216.g769fa