summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2011-03-29 15:03:25 +0200
committerChristian Halstrick <christian.halstrick@sap.com>2011-03-29 15:10:33 +0200
commiteac2dc18f11e517d995cf2db68d5675390daa02b (patch)
treea510078416e60bb3329e73cf552bf8d67bc8821d /org.eclipse.jgit
parentc8b698abb986b1c07d01a48d859c541aa8d1e9bb (diff)
downloadjgit-eac2dc18f11e517d995cf2db68d5675390daa02b.tar.gz
jgit-eac2dc18f11e517d995cf2db68d5675390daa02b.zip
Allow InitCommand to run on existing git repos
To be more consistent with what native git does we should allow to run the InitCommand also on existing git repos. Change-Id: I833637842631b37dce96ed9729b3a6ed24054056 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java
index 5b96cddac6..77fc3042c5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java
@@ -52,7 +52,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
/**
- * Create an empty git repository
+ * Create an empty git repository or reinitalize an existing one
*
* @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-init.html"
* >Git documentation about init</a>
@@ -89,7 +89,8 @@ public class InitCommand implements Callable<Git> {
builder.setGitDir(d);
}
Repository repository = builder.build();
- repository.create(bare);
+ if (!repository.getObjectDatabase().exists())
+ repository.create(bare);
return new Git(repository);
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);