Top Description Inners Fields Constructors Methods
org.eclipse.jgit.pgm

public abstract Class TextBuiltin

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.pgm.UploadPack, org.eclipse.jgit.pgm.Version, org.eclipse.jgit.pgm.debug.BenchmarkReftable, org.eclipse.jgit.pgm.debug.DiffAlgorithms, org.eclipse.jgit.pgm.debug.LfsStore, org.eclipse.jgit.pgm.debug.MakeCacheTree, org.eclipse.jgit.pgm.debug.ReadChangedPathFilter, org.eclipse.jgit.pgm.debug.ReadDirCache, org.eclipse.jgit.pgm.debug.ReadReftable, org.eclipse.jgit.pgm.debug.RebuildCommitGraph, org.eclipse.jgit.pgm.debug.ShowCacheTree, org.eclipse.jgit.pgm.debug.ShowCommands, org.eclipse.jgit.pgm.debug.ShowDirCache, org.eclipse.jgit.pgm.debug.ShowPackDelta, org.eclipse.jgit.pgm.debug.TextHashFunctions, org.eclipse.jgit.pgm.debug.VerifyReftable, org.eclipse.jgit.pgm.debug.WriteDirCache, org.eclipse.jgit.pgm.debug.WriteReftable, org.eclipse.jgit.pgm.AbstractFetchCommand, org.eclipse.jgit.pgm.Add, org.eclipse.jgit.pgm.AmazonS3Client, org.eclipse.jgit.pgm.Archive, org.eclipse.jgit.pgm.Blame, org.eclipse.jgit.pgm.Branch, org.eclipse.jgit.pgm.Checkout, org.eclipse.jgit.pgm.Clean, org.eclipse.jgit.pgm.Commit, org.eclipse.jgit.pgm.Config, org.eclipse.jgit.pgm.ConvertRefStorage, org.eclipse.jgit.pgm.Daemon, org.eclipse.jgit.pgm.Describe, org.eclipse.jgit.pgm.Diff, org.eclipse.jgit.pgm.DiffTool, org.eclipse.jgit.pgm.DiffTree, org.eclipse.jgit.pgm.Gc, org.eclipse.jgit.pgm.IndexPack, org.eclipse.jgit.pgm.Init, org.eclipse.jgit.pgm.LsFiles, org.eclipse.jgit.pgm.LsRemote, org.eclipse.jgit.pgm.LsTree, org.eclipse.jgit.pgm.Merge, org.eclipse.jgit.pgm.MergeBase, org.eclipse.jgit.pgm.MergeTool, org.eclipse.jgit.pgm.MultiPackIndex, org.eclipse.jgit.pgm.PackRefs, org.eclipse.jgit.pgm.Push, org.eclipse.jgit.pgm.ReceivePack, org.eclipse.jgit.pgm.Reflog, org.eclipse.jgit.pgm.Remote, org.eclipse.jgit.pgm.Repo, org.eclipse.jgit.pgm.Reset, org.eclipse.jgit.pgm.RevParse, org.eclipse.jgit.pgm.RevWalkTextBuiltin, org.eclipse.jgit.pgm.Rm, org.eclipse.jgit.pgm.Show, org.eclipse.jgit.pgm.ShowRef, org.eclipse.jgit.pgm.Status, org.eclipse.jgit.pgm.Tag
Static Imports
java.nio.charset.StandardCharsets.UTF_8, org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_LOG_OUTPUT_ENCODING, .ConfigConstants.CONFIG_SECTION_I18N, .Constants.R_HEADS, .Constants.R_REMOTES, .Constants.R_TAGS

Abstract command which can be invoked from the command line.

Commands are configured with a single "current" repository and then the execute(String[]) method is invoked with the arguments that appear on the command line after the command name.

Command constructors should perform as little work as possible as they may be invoked very early during process loading, and the command may not execute even though it was constructed.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
TextBuiltin.TerminatedByHelpException

Exception thrown by TextBuiltin if it proceeds 'help' option

Field Summary

Modifier and TypeField and Description
protected RevWalk
argWalk

RevWalk used during command line parsing, if it was required.

private String
protected Repository
db

Git repository the command was invoked within.

protected OutputStream
errs

Error output stream, typically this is standard error.

protected ThrowingPrintWriter
errw

Error writer, typically this is standard error.

protected String
gitdir

Directory supplied via --git-dir command line option.

private boolean
protected InputStream
ins

Input stream, typically this is standard input.

protected OutputStream
outs

Stream to output to, typically this is standard output.

protected ThrowingPrintWriter
outw

Writer to output to, typically this is standard output.

private SshDriver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv String
abbreviateRef(String dst, boolean abbreviateRemote)

public static boolean

Returns:

true if the given array contains help option
containsHelp
(String[]
non null
args
)

Check if the arguments contain a help option

protected static Die

Returns:

a runtime exception the caller is expected to throw
die
(String
textual explanation
why
)

Exit the command with an error message

protected static Die

Returns:

a runtime exception the caller is expected to throw
die
(String
textual explanation
why
,
Throwable
why the command has failed.
cause
)

Exit the command with an error message and an exception

protected static Die

Returns:

a runtime exception the caller is expected to throw
die
(boolean
boolean indicating that the execution has been aborted before running
aborted
)

Exit the command

protected static Die

Returns:

a runtime exception the caller is expected to throw
die
(boolean
boolean indicating that the execution has been aborted before running
aborted
,
Throwable
why the command has failed.
cause
)

Exit the command

public final void
execute(String[]
command line arguments passed after the command name.
args
)

Parse arguments and run this command.

public ThrowingPrintWriter

Returns:

error writer, typically this is standard error.
getErrorWriter
()

Get error writer

private Charset

Returns:

Charset corresponding to i18n.logOutputEncoding, or UTF_8.
getLogOutputEncodingCharset
(Repository
the repository.
repository
)

Get the log output encoding specified in the repository's i18n.logOutputEncoding configuration.

public ThrowingPrintWriter

Returns:

output writer, typically this is standard output.
getOutputWriter
()

Get output writer

public Repository

Returns:

the repository this command accesses.
getRepository
()

Get the repository

protected ResourceBundle

Returns:

the resource bundle that will be passed to args4j for purpose of string localization
getResourceBundle
()

Get resource bundle with localized texts

protected void
init(Repository
the opened repository that the command should work on.
repository
,
String
value of the --git-dir command line option, if repository is null.
gitDir
)

Initialize the command to work with a repository.

public void
initRaw(final Repository
the opened repository that the command should work on.
repository
,
final String
value of the --git-dir command line option, if repository is null.
gitDir
,
InputStream
input stream from which input will be read
input
,
OutputStream
output stream to which output will be written
output
,
OutputStream
error stream to which errors will be written
error
)

Initializes the command to work with a repository, including setting the output and error streams.

protected void
parseArguments(String[]
the arguments supplied on the command line, if any.
args
)

Parses the command line arguments prior to running.

protected void
printUsage(String
non null
message
,
CmdLineParser
parser used to print options
clp
)

Print usage help text.

public void
public void
printUsageAndExit(String message, CmdLineParser clp)

Print an error message and the usage line

protected boolean

Returns:

true if db/getRepository() is required
requiresRepository
()

If this command requires a repository.

pack-priv ObjectId
protected abstract void
run()

Perform the actions of this command.

pack-priv final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argWalkback to summary
protected RevWalk argWalk

RevWalk used during command line parsing, if it was required.

commandNameback to summary
private String commandName
dbback to summary
protected Repository db

Git repository the command was invoked within.

errsback to summary
protected OutputStream errs

Error output stream, typically this is standard error.

Since
3.4
errwback to summary
protected ThrowingPrintWriter errw

Error writer, typically this is standard error.

Since
3.4
gitdirback to summary
protected String gitdir

Directory supplied via --git-dir command line option.

helpback to summary
private boolean help
Annotations
@Option
name:--help
usage:usage_displayThisHelpText
aliases:-h
insback to summary
protected InputStream ins

Input stream, typically this is standard input.

Since
3.4
outsback to summary
protected OutputStream outs

Stream to output to, typically this is standard output.

Since
2.2
outwback to summary
protected ThrowingPrintWriter outw

Writer to output to, typically this is standard output.

Since
2.2
sshDriverback to summary
private SshDriver sshDriver
Annotations
@Option
name:--ssh
usage:usage_sshDriver

Constructor Detail

TextBuiltinback to summary
public TextBuiltin()

Method Detail

abbreviateRefback to summary
pack-priv String abbreviateRef(String dst, boolean abbreviateRemote)
containsHelpback to summary
public static boolean containsHelp(String[] args)

Check if the arguments contain a help option

Parameters
args:String[]

non null

Returns:boolean

true if the given array contains help option

Since
4.2
dieback to summary
protected static Die die(String why)

Exit the command with an error message

Parameters
why:String

textual explanation

Returns:Die

a runtime exception the caller is expected to throw

dieback to summary
protected static Die die(String why, Throwable cause)

Exit the command with an error message and an exception

Parameters
why:String

textual explanation

cause:Throwable

why the command has failed.

Returns:Die

a runtime exception the caller is expected to throw

dieback to summary
protected static Die die(boolean aborted)

Exit the command

Parameters
aborted:boolean

boolean indicating that the execution has been aborted before running

Returns:Die

a runtime exception the caller is expected to throw

Since
3.4
dieback to summary
protected static Die die(boolean aborted, Throwable cause)

Exit the command

Parameters
aborted:boolean

boolean indicating that the execution has been aborted before running

cause:Throwable

why the command has failed.

Returns:Die

a runtime exception the caller is expected to throw

Since
4.2
executeback to summary
public final void execute(String[] args) throws Exception

Parse arguments and run this command.

Parameters
args:String[]

command line arguments passed after the command name.

Exceptions
Exception:
an error occurred while processing the command. The main framework will catch the exception and print a message on standard error.
getErrorWriterback to summary
public ThrowingPrintWriter getErrorWriter()

Get error writer

Returns:ThrowingPrintWriter

error writer, typically this is standard error.

Since
4.2
getLogOutputEncodingCharsetback to summary
private Charset getLogOutputEncodingCharset(Repository repository)

Get the log output encoding specified in the repository's i18n.logOutputEncoding configuration.

Parameters
repository:Repository

the repository.

Returns:Charset

Charset corresponding to i18n.logOutputEncoding, or UTF_8.

getOutputWriterback to summary
public ThrowingPrintWriter getOutputWriter()

Get output writer

Returns:ThrowingPrintWriter

output writer, typically this is standard output.

Since
4.9
getRepositoryback to summary
public Repository getRepository()

Get the repository

Returns:Repository

the repository this command accesses.

getResourceBundleback to summary
protected ResourceBundle getResourceBundle()

Get resource bundle with localized texts

Returns:ResourceBundle

the resource bundle that will be passed to args4j for purpose of string localization

initback to summary
protected void init(Repository repository, String gitDir)

Initialize the command to work with a repository.

Parameters
repository:Repository

the opened repository that the command should work on.

gitDir:String

value of the --git-dir command line option, if repository is null.

initRawback to summary
public void initRaw(final Repository repository, final String gitDir, InputStream input, OutputStream output, OutputStream error)

Initializes the command to work with a repository, including setting the output and error streams.

Parameters
repository:Repository

the opened repository that the command should work on.

gitDir:String

value of the --git-dir command line option, if repository is null.

input:InputStream

input stream from which input will be read

output:OutputStream

output stream to which output will be written

error:OutputStream

error stream to which errors will be written

Since
4.9
parseArgumentsback to summary
protected void parseArguments(String[] args) throws IOException

Parses the command line arguments prior to running.

This method should only be invoked by execute(String[]), prior to calling run(). The default implementation parses all arguments into this object's instance fields.

Parameters
args:String[]

the arguments supplied on the command line, if any.

Exceptions
IOException:
if an IO error occurred
printUsageback to summary
protected void printUsage(String message, CmdLineParser clp) throws IOException

Print usage help text.

Parameters
message:String

non null

clp:CmdLineParser

parser used to print options

Exceptions
IOException:
if an IO error occurred
Since
4.2
printUsageAndExitback to summary
public void printUsageAndExit(CmdLineParser clp) throws IOException

Print the usage line

Parameters
clp:CmdLineParser

a org.eclipse.jgit.pgm.opt.CmdLineParser object.

Exceptions
IOException:
if an IO error occurred
printUsageAndExitback to summary
public void printUsageAndExit(String message, CmdLineParser clp) throws IOException

Print an error message and the usage line

Parameters
message:String

a java.lang.String object.

clp:CmdLineParser

a org.eclipse.jgit.pgm.opt.CmdLineParser object.

Exceptions
IOException:
if an IO error occurred
requiresRepositoryback to summary
protected boolean requiresRepository()

If this command requires a repository.

Returns:boolean

true if db/getRepository() is required

resolveback to summary
pack-priv ObjectId resolve(String s) throws IOException
runback to summary
protected abstract void run() throws Exception

Perform the actions of this command.

This method should only be invoked by execute(String[]).

Exceptions
Exception:
an error occurred while processing the command. The main framework will catch the exception and print a message on standard error.
setCommandNameback to summary
pack-priv final void setCommandName(String name)
org.eclipse.jgit.pgm back to summary

public Class TextBuiltin.TerminatedByHelpException

extends Die
Class Inheritance

Exception thrown by TextBuiltin if it proceeds 'help' option
Since
4.2

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
TerminatedByHelpException()

Default constructor

Method Summary

Inherited from org.eclipse.jgit.pgm.Die:
isAborted

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.eclipse.jgit.pgm.Die.serialVersionUID.

Constructor Detail

TerminatedByHelpExceptionback to summary
public TerminatedByHelpException()

Default constructor