git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [Bug Report] Git does not push signingkey ID to GPG
@ 2021-07-22 23:42 Oliver Niebuhr
  2021-07-23  7:07 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Niebuhr @ 2021-07-22 23:42 UTC (permalink / raw)
  To: git

Hello.

Using 'git commit -S' (uppercase S) to gpg sign a commit does not work. 
It seems that Git does not push the ID to GPG.

When I use 'git commit --gpg-sign=[KEY]', it works as expected.

What do I try to achieve: Automate adding 'Signed-off-by' and 
automatically sign with the gpg key.

It should work from CMD Line as well from within an IDE.

I have edit the .gitconfig File accordingly and added

[user]
signingkey = NNN
[commit]
gpgsign = true
[alias]
amend = commit -S -s --amend
cm = commit -S -s
commit = commit -S -s
tag = tag -S -s
[gpg]
program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe

The Git User Name and eMail Address are the same which are set in the 
used GPG Certificate.

Using '-S' from the Windows CMD Shell and Git Bash leads to an error. 
Neither typing the command manually or using it through an alias works.

When I switch '-S' with '--gpg-sign=NNN' everything works as it should 
from CMD Line - but not when I use for example SmartGit and enable 'Sign 
all Commits'. After countless hours looking through the Web, I am not 
out of Ideas.

Here is the Trace:
C:\Dev\GitRepos\Test>git cm
00:30:36.873133 exec-cmd.c:237      trace: resolved executable dir: 
C:/Dev/Git/mingw64/bin
00:30:36.874133 git.c:744           trace: exec: git-cm
00:30:36.874133 run-command.c:667   trace: run_command: git-cm
00:30:36.876134 git.c:396           trace: alias expansion: cm => commit 
-S -s
00:30:36.876134 git.c:805           trace: exec: git commit -S -s
00:30:36.876134 run-command.c:667   trace: run_command: git commit -S -s
00:30:36.883142 exec-cmd.c:237      trace: resolved executable dir: 
C:/Dev/Git/mingw64/libexec/git-core
00:30:36.884143 git.c:455           trace: built-in: git commit -S -s

hint: Waiting for your editor to close the file... 00:30:36.889147 
run-command.c:667       trace: run_command: GIT_INDEX_FILE=.git/index 
'"C:/Dev/GitGuis/GitExtensions/GitExtensions.exe" fileeditor' 
C:/Dev/GitRepos/Test/.git/COMMIT_EDITMSG
00:30:45.064284 run-command.c:667       trace: run_command: 'C:\Program 
Files (x86)\GnuPG\bin\gpg.exe' -bsau ''
gpg: skipped "": Invalid user ID
gpg: signing failed: Invalid user ID
error: gpg failed to sign the data
fatal: failed to write commit object

Windows: Windows 10 Pro, 21H1, 19043.1100
Git Version: git version 2.32.0.windows.2
GPG Version: gpg (GnuPG) 2.2.28, libgcrypt 1.8.8, Copyright (C) 2021 g10 
Code GmbH

Thank you in advance!
Oliver Niebuhr

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Bug Report] Git does not push signingkey ID to GPG
  2021-07-22 23:42 [Bug Report] Git does not push signingkey ID to GPG Oliver Niebuhr
@ 2021-07-23  7:07 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2021-07-23  7:07 UTC (permalink / raw)
  To: Oliver Niebuhr; +Cc: git

On Fri, Jul 23, 2021 at 01:42:20AM +0200, Oliver Niebuhr wrote:

> I have edit the .gitconfig File accordingly and added
> 
> [user]
> signingkey = NNN
> [commit]
> gpgsign = true
> [alias]
> amend = commit -S -s --amend
> cm = commit -S -s
> commit = commit -S -s
> tag = tag -S -s
> [gpg]
> program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
> 
> The Git User Name and eMail Address are the same which are set in the used
> GPG Certificate.
> 
> Using '-S' from the Windows CMD Shell and Git Bash leads to an error.
> Neither typing the command manually or using it through an alias works.
> 
> When I switch '-S' with '--gpg-sign=NNN' everything works as it should from
> CMD Line - but not when I use for example SmartGit and enable 'Sign all
> Commits'. After countless hours looking through the Web, I am not out of
> Ideas.

This works fine for me. I get:

  $ GIT_TRACE=1 git -c user.signingkey=1234abcd commit -S --amend --no-edit
  03:03:26.487264 [pid=1285432] git.c:455           trace: built-in: git commit -S --amend --no-edit
  03:03:26.491963 [pid=1285432] run-command.c:666   trace: run_command: gpg --status-fd=2 -bsau 1234abcd
  error: gpg failed to sign the data
  fatal: failed to write commit object

In your trace, the key parameter that's passed is the empty string:

> 00:30:45.064284 run-command.c:667       trace: run_command: 'C:\Program
> Files (x86)\GnuPG\bin\gpg.exe' -bsau ''
> gpg: skipped "": Invalid user ID
> gpg: signing failed: Invalid user ID

You showed config with user.signingkey set. Is it possible that you have
other config (say, in the repo config file), that is taking precedence?

What does:

  git config --show-origin --get-all user.signingkey

say when run inside the repository?

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-23  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 23:42 [Bug Report] Git does not push signingkey ID to GPG Oliver Niebuhr
2021-07-23  7:07 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).