diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2022-04-03 20:33:37 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2022-04-14 10:52:55 +0200 |
commit | 7e06e51750d7eeae111237f6d527bc295b07e8c2 (patch) | |
tree | e947e9b3235dadd877549815ca785ba4ebb8404d | |
parent | fbce3122e0e41b497ac6e2a8176d46f90d302671 (diff) | |
download | jgit-7e06e51750d7eeae111237f6d527bc295b07e8c2.tar.gz jgit-7e06e51750d7eeae111237f6d527bc295b07e8c2.zip |
CommitCommand: call GpgSigner.getDefault() only if indeed signing
If we're not signing the commit, we don't need the GpgSigner at all.
Change-Id: Ica35651c73d82b7604c8a67487b0d9474c908aae
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index d0a7947894..3b3baf5a12 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -323,8 +323,14 @@ public class CommitCommand extends GitCommand<RevCommit> { private void sign(CommitBuilder commit) throws ServiceUnavailableException, CanceledException, UnsupportedSigningFormatException { if (gpgSigner == null) { - throw new ServiceUnavailableException( - JGitText.get().signingServiceUnavailable); + gpgSigner = GpgSigner.getDefault(); + if (gpgSigner == null) { + throw new ServiceUnavailableException( + JGitText.get().signingServiceUnavailable); + } + } + if (signingKey == null) { + signingKey = gpgConfig.getSigningKey(); } if (gpgSigner instanceof GpgObjectSigner) { ((GpgObjectSigner) gpgSigner).signObject(commit, @@ -659,12 +665,6 @@ public class CommitCommand extends GitCommand<RevCommit> { signCommit = gpgConfig.isSignCommits() ? Boolean.TRUE : Boolean.FALSE; } - if (signingKey == null) { - signingKey = gpgConfig.getSigningKey(); - } - if (gpgSigner == null) { - gpgSigner = GpgSigner.getDefault(); - } } private boolean isMergeDuringRebase(RepositoryState state) { |