Browse Source

Update Init to use InitCommand

Change-Id: I3ff700a87dfa6ac255c1aaf3fe11a07264594aab
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
stable-0.10
Chris Aniszczyk 14 years ago
parent
commit
8f6c8818dc
  1. 16
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

16
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

@ -3,6 +3,7 @@
* Copyright (C) 2008, Google Inc. * Copyright (C) 2008, Google Inc.
* Copyright (C) 2010, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com>
* Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
* This program and the accompanying materials are made available * This program and the accompanying materials are made available
@ -46,12 +47,11 @@
package org.eclipse.jgit.pgm; package org.eclipse.jgit.pgm;
import java.io.File;
import java.text.MessageFormat; import java.text.MessageFormat;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.InitCommand;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.storage.file.FileRepository;
@Command(common = true, usage = "usage_CreateAnEmptyGitRepository") @Command(common = true, usage = "usage_CreateAnEmptyGitRepository")
class Init extends TextBuiltin { class Init extends TextBuiltin {
@ -65,12 +65,10 @@ class Init extends TextBuiltin {
@Override @Override
protected void run() throws Exception { protected void run() throws Exception {
if (gitdir == null) InitCommand command = Git.init();
gitdir = new File(bare ? "." : Constants.DOT_GIT); command.setBare(bare);
else command.setDirectory(gitdir);
bare = true; command.call();
db = new FileRepository(gitdir);
db.create(bare);
out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath())); out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath()));
} }
} }

Loading…
Cancel
Save