[JGIT PATCH 10/19] Test for the config file when creating a new repository

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <spearce@xxxxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]