From: Shawn O. Pearce Date: Sat, 25 Jul 2009 18:52:53 GMT Subject: [JGIT PATCH 10/19] Test for the config file when creating a new repository Message-ID: <1248547982-4003-11-git-send-email-spearce@spearce.org> In-Reply-To: <1248547982-4003-10-git-send-email-spearce@spearce.org> 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 --- .../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