Package org.eclipse.jgit.pgm
Class CLIGitCommand
- java.lang.Object
-
- org.eclipse.jgit.pgm.Main
-
- org.eclipse.jgit.pgm.CLIGitCommand
-
public class CLIGitCommand extends Main
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCLIGitCommand.Result-
Nested classes/interfaces inherited from class org.eclipse.jgit.pgm.Main
Main.SubcommandLineParser
-
-
Field Summary
Fields Modifier and Type Field Description private Repositorydbprivate CLIGitCommand.Resultresult
-
Constructor Summary
Constructors Constructor Description CLIGitCommand(Repository db)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String[]convertToMainArgs(java.lang.String str)(package private) java.io.PrintWritercreateErrorWriter()static java.util.List<java.lang.String>execute(java.lang.String str, Repository db)static CLIGitCommand.ResultexecuteRaw(java.lang.String str, Repository db)static java.util.List<java.lang.String>executeUnchecked(java.lang.String str, Repository db)(package private) voidexit(int status, java.lang.Exception t)private static java.util.List<java.lang.String>getOutput(CLIGitCommand.Result result)(package private) voidinit(TextBuiltin cmd)static voidmain(java.lang.String[] args)Executes git commands (with arguments) specified on the command line.protected RepositoryopenGitDir(java.lang.String aGitdir)Evaluate the--git-diroption and open the repository.private voidrun(java.lang.String commandLine)(package private) static java.lang.String[]split(java.lang.String commandLine)Split a command line into a string array.-
Methods inherited from class org.eclipse.jgit.pgm.Main
configureHttpProxy, run
-
-
-
-
Field Detail
-
result
private final CLIGitCommand.Result result
-
db
private final Repository db
-
-
Constructor Detail
-
CLIGitCommand
public CLIGitCommand(Repository db)
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionExecutes git commands (with arguments) specified on the command line. The git repository (same for all commands) can be specified via system property "-Dgit_work_tree=path_to_work_tree". If the property is not set, current directory is used.- Parameters:
args- each element in the array must be a valid git command line, e.g. "git branch -h"- Throws:
java.lang.Exception
-
execute
public static java.util.List<java.lang.String> execute(java.lang.String str, Repository db) throws java.lang.Exception- Throws:
java.lang.Exception
-
executeRaw
public static CLIGitCommand.Result executeRaw(java.lang.String str, Repository db) throws java.lang.Exception
- Throws:
java.lang.Exception
-
executeUnchecked
public static java.util.List<java.lang.String> executeUnchecked(java.lang.String str, Repository db) throws java.lang.Exception- Throws:
java.lang.Exception
-
getOutput
private static java.util.List<java.lang.String> getOutput(CLIGitCommand.Result result)
-
run
private void run(java.lang.String commandLine) throws java.lang.Exception- Throws:
java.lang.Exception
-
convertToMainArgs
private static java.lang.String[] convertToMainArgs(java.lang.String str) throws java.lang.Exception- Throws:
java.lang.Exception
-
createErrorWriter
java.io.PrintWriter createErrorWriter()
- Overrides:
createErrorWriterin classMain
-
init
void init(TextBuiltin cmd) throws java.io.IOException
-
openGitDir
protected Repository openGitDir(java.lang.String aGitdir) throws java.io.IOException
Description copied from class:MainEvaluate the--git-diroption and open the repository.- Overrides:
openGitDirin classMain- Parameters:
aGitdir- the--git-diroption given on the command line. May be null if it was not supplied.- Returns:
- the repository to operate on.
- Throws:
java.io.IOException- the repository cannot be opened.
-
exit
void exit(int status, java.lang.Exception t) throws java.lang.Exception
-
split
static java.lang.String[] split(java.lang.String commandLine)
Split a command line into a string array. A copy of Gerrit's com.google.gerrit.sshd.CommandFactoryProvider#split(String)- Parameters:
commandLine- a command line- Returns:
- the array
-
-