Browse Source

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>
stable-0.12
Christian Halstrick 14 years ago
parent
commit
eac2dc18f1
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java

3
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,6 +89,7 @@ public class InitCommand implements Callable<Git> {
builder.setGitDir(d);
}
Repository repository = builder.build();
if (!repository.getObjectDatabase().exists())
repository.create(bare);
return new Git(repository);
} catch (IOException e) {

Loading…
Cancel
Save