Commit command. It has setters for all
supported options and arguments of this command and a call() method
to finally execute the command.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private Boolean | |
| private boolean | |
| private PersonIdent | |
| private boolean | |
| private CommitConfig. | |
| private Character | |
| private PersonIdent | |
| private CredentialsProvider | |
| private GpgConfig | |
| private HashMap | |
| private HashMap | |
| private boolean | |
| private static final Logger | |
| private String | |
| private boolean | noVerify
Setting this option bypasses the pre-commit and commit-msg hooks. |
| private List | |
| private boolean[] | |
| private List | parents
parents this commit should have. |
| private String | |
| private Boolean | |
| private Signer | |
| private String | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public RevCommit | call()
Implements abstract org. Implements java. Computes a result, or throws an exception if unable to do so. |
| private void | |
| private DirCache | |
| public PersonIdent | Returns: the author used for thecommit. If no author was
specified null is returned and the default
org. of this repo is used
during execution of the commandGet the author |
| public PersonIdent | Returns: the committer used for thecommit. If no committer was
specified null is returned and the default
org. of this repo is used
during execution of the commandGet the committer |
| public String | |
| private void | |
| private boolean | |
| private int | Returns: the item's index inonly; -1 if no item matchesentry's path pathString)Look an entry's path up in the list of paths specified by the --only/ -o
option
In case the complete (file) path (e.g. "d1/d2/f1") cannot be found in
|
| private void | processOptions(RepositoryState
the state of the repository we are working on state, RevWalk the RevWalk to use rw)Sets default values for not explicitly specified options. |
| public CommitCommand | Returns: thiswhether to auto-stage all files that have been modified and
deleted all)If set to true the Commit command automatically stages files that have been modified and deleted, but new files not known by the repository are not affected. |
| public CommitCommand | Returns: thiswhether it should be allowed to create a commit which has the
same tree as it's sole predecessor (a commit which doesn't
change anything). By default when creating standard commits
(without specifying paths) JGit allows to create such commits.
When this flag is set to false an attempt to create an "empty"
standard commit will lead to an EmptyCommitException.
allowEmpty)
By default when creating a commit containing only specified
paths an attempt to create an empty commit leads to a
Set whether to allow to create an empty commit |
| public CommitCommand | Returns: thiswhether to amend the tip of the current branch amend)Used to amend the tip of the current branch. |
| public CommitCommand | Returns: thisthe author used for the author)commitSets the author for this |
| public CommitCommand | |
| public CommitCommand | Returns: thisCleanupMode to setSets the |
| public CommitCommand | Returns: thisthe comment character, or commentChar)null to use the value from
the git configSets the comment character to apply when cleaning a commit message. |
| public CommitCommand | Returns: thisthe committer used for the committer)commitSets the committer for this |
| public CommitCommand | Returns: thisthe name of the committer used for the name, String committhe email of the committer used for the email)commitSets the committer for this |
| public CommitCommand | Returns: thisthe provider to use when querying for credentials (eg., during
signing) credentialsProvider)Sets a |
| public CommitCommand | Returns: thisSets the default clean mode if |
| public CommitCommand | Returns: thisto set; if config)null, the config will be loaded from the
git config of the repositorySets an external |
| public CommitCommand | Returns: thisthe error stream for hook scripts executed by this command hookStdErr)Set the error stream for all hook scripts executed by this command (pre-commit, commit-msg, post-commit). |
| public CommitCommand | Returns: thisname of the hook to set the output stream for hookName, PrintStream the output stream to use for the selected hook hookStdErr)Set the error stream for a selected hook script executed by this command (pre-commit, commit-msg, post-commit). |
| public CommitCommand | Returns: thisthe output stream for hook scripts executed by this command hookStdOut)Set the output stream for all hook scripts executed by this command (pre-commit, commit-msg, post-commit). |
| public CommitCommand | Returns: thisname of the hook to set the output stream for hookName, PrintStream the output stream to use for the selected hook hookStdOut)Set the output stream for a selected hook script executed by this command (pre-commit, commit-msg, post-commit). |
| public CommitCommand | Returns: thiswhether to insert a change id insertChangeId)If set to true a change id will be inserted into the commit message An existing change id is not replaced. |
| public CommitCommand | |
| public CommitCommand | Returns: thisWhether this commit should be verified by the pre-commit and
commit-msg hooks. noVerify)Sets the |
| public CommitCommand | |
| public CommitCommand | Returns: thisthe comment to be written into the reflog or reflogComment)null
to specify that no reflog should be writtenOverride the message written to the reflog |
| public CommitCommand | |
| public CommitCommand | |
| public CommitCommand | Returns: thissigning key (maybe signingKey)null)Sets the signing key Per spec of user.signingKey: this will be sent to the GPG program as is, i.e. can be anything supported by the GPG program. |
| private void | |
| private void |
| all | back to summary |
|---|---|
| private boolean all | |
| allowEmpty | back to summary |
|---|---|
| private Boolean allowEmpty | |
| amend | back to summary |
|---|---|
| private boolean amend | |
| author | back to summary |
|---|---|
| private PersonIdent author | |
| cleanDefaultIsStrip | back to summary |
|---|---|
| private boolean cleanDefaultIsStrip | |
| cleanupMode | back to summary |
|---|---|
| private CommitConfig. | |
| commentChar | back to summary |
|---|---|
| private Character commentChar | |
| committer | back to summary |
|---|---|
| private PersonIdent committer | |
| credentialsProvider | back to summary |
|---|---|
| private CredentialsProvider credentialsProvider | |
| gpgConfig | back to summary |
|---|---|
| private GpgConfig gpgConfig | |
| hookErrRedirect | back to summary |
|---|---|
| private HashMap<String, PrintStream> hookErrRedirect | |
| hookOutRedirect | back to summary |
|---|---|
| private HashMap<String, PrintStream> hookOutRedirect | |
| insertChangeId | back to summary |
|---|---|
| private boolean insertChangeId | |
| log | back to summary |
|---|---|
| private static final Logger log | |
| message | back to summary |
|---|---|
| private String message | |
| noVerify | back to summary |
|---|---|
| private boolean noVerify Setting this option bypasses the pre-commit and commit-msg hooks. | |
| only | back to summary |
|---|---|
| private List<String> only | |
| onlyProcessed | back to summary |
|---|---|
| private boolean[] onlyProcessed | |
| parents | back to summary |
|---|---|
| private List<ObjectId> parents parents this commit should have. The current HEAD will be in this list and also all commits mentioned in .git/MERGE_HEAD | |
| reflogComment | back to summary |
|---|---|
| private String reflogComment | |
| signCommit | back to summary |
|---|---|
| private Boolean signCommit | |
| signer | back to summary |
|---|---|
| private Signer signer | |
| signingKey | back to summary |
|---|---|
| private String signingKey | |
| useDefaultReflogMessage | back to summary |
|---|---|
| private boolean useDefaultReflogMessage | |
| CommitCommand | back to summary |
|---|---|
| protected CommitCommand(Repository repo) Constructor for CommitCommand
| |
| call | back to summary |
|---|---|
| public RevCommit call() throws GitAPIException, AbortedByHookException, ConcurrentRefUpdateException, NoHeadException, NoMessageException, ServiceUnavailableException, UnmergedPathsException, WrongRepositoryStateException Implements abstract org. Implements java. Doc from org. Computes a result, or throws an exception if unable to do so. Execute the command
Executes the
| |
| checkIfEmpty | back to summary |
|---|---|
| private void checkIfEmpty(RevWalk rw, ObjectId headId, ObjectId indexTreeId) throws EmptyCommitException, MissingObjectException, IncorrectObjectTypeException, IOException | |
| createTemporaryIndex | back to summary |
|---|---|
| private DirCache createTemporaryIndex(ObjectId headId, DirCache index, RevWalk rw) throws IOException | |
| getAuthor | back to summary |
|---|---|
| public PersonIdent getAuthor() Get the author
| |
| getCommitter | back to summary |
|---|---|
| public PersonIdent getCommitter() Get the committer
| |
| getMessage | back to summary |
|---|---|
| public String getMessage() Get the commit message
| |
| insertChangeId | back to summary |
|---|---|
| private void insertChangeId(ObjectId treeId) | |
| isMergeDuringRebase | back to summary |
|---|---|
| private boolean isMergeDuringRebase(RepositoryState state) | |
| lookupOnly | back to summary |
|---|---|
| private int lookupOnly(String pathString) Look an entry's path up in the list of paths specified by the --only/ -o
option
In case the complete (file) path (e.g. "d1/d2/f1") cannot be found in
| |
| processOptions | back to summary |
|---|---|
| private void processOptions(RepositoryState state, RevWalk rw) throws NoMessageException, UnsupportedSigningFormatException Sets default values for not explicitly specified options. Then validates that all required data has been provided.
| |
| setAll | back to summary |
|---|---|
| public CommitCommand setAll(boolean all) If set to true the Commit command automatically stages files that have been modified and deleted, but new files not known by the repository are not affected. This corresponds to the parameter -a on the command line.
| |
| setAllowEmpty | back to summary |
|---|---|
| public CommitCommand setAllowEmpty(boolean allowEmpty) Set whether to allow to create an empty commit
| |
| setAmend | back to summary |
|---|---|
| public CommitCommand setAmend(boolean amend) Used to amend the tip of the current branch. If set to
| |
| setAuthor | back to summary |
|---|---|
| public CommitCommand setAuthor(PersonIdent author) Sets the author for this
| |
| setAuthor | back to summary |
|---|---|
| public CommitCommand setAuthor(String name, String email) Sets the author for this
| |
| setCleanupMode | back to summary |
|---|---|
| public CommitCommand setCleanupMode(CommitConfig. Sets the
| |
| setCommentCharacter | back to summary |
|---|---|
| public CommitCommand setCommentCharacter(Character commentChar) Sets the comment character to apply when cleaning a commit message. If
| |
| setCommitter | back to summary |
|---|---|
| public CommitCommand setCommitter(PersonIdent committer) Sets the committer for this
| |
| setCommitter | back to summary |
|---|---|
| public CommitCommand setCommitter(String name, String email) Sets the committer for this
| |
| setCredentialsProvider | back to summary |
|---|---|
| public CommitCommand setCredentialsProvider(CredentialsProvider credentialsProvider) Sets a
| |
| setDefaultClean | back to summary |
|---|---|
| public CommitCommand setDefaultClean(boolean strip) Sets the default clean mode if
| |
| setGpgConfig | back to summary |
|---|---|
| public CommitCommand setGpgConfig(GpgConfig config) Sets an external
| |
| setHookErrorStream | back to summary |
|---|---|
| public CommitCommand setHookErrorStream(PrintStream hookStdErr) Set the error stream for all hook scripts executed by this command
(pre-commit, commit-msg, post-commit). If not set it defaults to
| |
| setHookErrorStream | back to summary |
|---|---|
| public CommitCommand setHookErrorStream(String hookName, PrintStream hookStdErr) Set the error stream for a selected hook script executed by this command
(pre-commit, commit-msg, post-commit). If not set it defaults to
| |
| setHookOutputStream | back to summary |
|---|---|
| public CommitCommand setHookOutputStream(PrintStream hookStdOut) Set the output stream for all hook scripts executed by this command
(pre-commit, commit-msg, post-commit). If not set it defaults to
| |
| setHookOutputStream | back to summary |
|---|---|
| public CommitCommand setHookOutputStream(String hookName, PrintStream hookStdOut) Set the output stream for a selected hook script executed by this command
(pre-commit, commit-msg, post-commit). If not set it defaults to
| |
| setInsertChangeId | back to summary |
|---|---|
| public CommitCommand setInsertChangeId(boolean insertChangeId) If set to true a change id will be inserted into the commit message An existing change id is not replaced. An initial change id (I000...) will be replaced by the change id.
| |
| setMessage | back to summary |
|---|---|
| public CommitCommand setMessage(String message) Set the commit message
| |
| setNoVerify | back to summary |
|---|---|
| public CommitCommand setNoVerify(boolean noVerify) Sets the
Both the pre-commit and commit-msg hooks can block a commit by their
return value; setting this option to
| |
| setOnly | back to summary |
|---|---|
| public CommitCommand setOnly(String only) Commit dedicated path only. This method can be called several times to add multiple paths. Full file paths are supported as well as directory paths; in the latter case this commits all files/directories below the specified path.
| |
| setReflogComment | back to summary |
|---|---|
| public CommitCommand setReflogComment(String reflogComment) Override the message written to the reflog
| |
| setSign | back to summary |
|---|---|
| public CommitCommand setSign(Boolean sign) Sets whether the commit should be signed.
| |
| setSigner | back to summary |
|---|---|
| public CommitCommand setSigner(Signer signer) Sets the
| |
| setSigningKey | back to summary |
|---|---|
| public CommitCommand setSigningKey(String signingKey) Sets the signing key Per spec of user.signingKey: this will be sent to the GPG program as is, i.e. can be anything supported by the GPG program.
Note, if none was set or
| |
| sign | back to summary |
|---|---|
| private void sign(CommitBuilder commit) throws CanceledException, IOException, UnsupportedSigningFormatException | |
| updateRef | back to summary |
|---|---|
| private void updateRef(RepositoryState state, ObjectId headId, RevCommit revCommit, ObjectId commitId) throws ConcurrentRefUpdateException, IOException | |