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 d0a794789..3b3baf5a1 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 @@ private void checkIfEmpty(RevWalk rw, ObjectId headId, ObjectId indexTreeId) 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 @@ private void processOptions(RepositoryState state, RevWalk rw) signCommit = gpgConfig.isSignCommits() ? Boolean.TRUE : Boolean.FALSE; } - if (signingKey == null) { - signingKey = gpgConfig.getSigningKey(); - } - if (gpgSigner == null) { - gpgSigner = GpgSigner.getDefault(); - } } private boolean isMergeDuringRebase(RepositoryState state) {