{"thread":{"id":"56149","subject":"[Bug Report] Git does not push signingkey ID to GPG","startedAt":"2021-07-23T00:07:41Z","lastAt":"2021-07-23T07:07:05Z","messageCount":2,"participants":["Oliver Niebuhr","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"430979","messageId":"dfeebef5-6f48-082d-f49d-832863ff62a8@oliverniebuhr.de","threadId":"56149","inReplyTo":null,"subject":"[Bug Report] Git does not push signingkey ID to GPG","fromName":"Oliver Niebuhr","fromEmail":"oliver.niebuhr@oliverniebuhr.de","sentAt":"2021-07-22T23:42:20Z","receivedAt":"2021-07-23T00:07:41Z","isPatch":false,"sender":{"key":"oliver.niebuhr@oliverniebuhr.de","avatar":null},"body":"Hello.\n\nUsing 'git commit -S' (uppercase S) to gpg sign a commit does not work. \nIt seems that Git does not push the ID to GPG.\n\nWhen I use 'git commit --gpg-sign=[KEY]', it works as expected.\n\nWhat do I try to achieve: Automate adding 'Signed-off-by' and \nautomatically sign with the gpg key.\n\nIt should work from CMD Line as well from within an IDE.\n\nI have edit the .gitconfig File accordingly and added\n\n[user]\nsigningkey = NNN\n[commit]\ngpgsign = true\n[alias]\namend = commit -S -s --amend\ncm = commit -S -s\ncommit = commit -S -s\ntag = tag -S -s\n[gpg]\nprogram = C:\\\\Program Files (x86)\\\\GnuPG\\\\bin\\\\gpg.exe\n\nThe Git User Name and eMail Address are the same which are set in the \nused GPG Certificate.\n\nUsing '-S' from the Windows CMD Shell and Git Bash leads to an error. \nNeither typing the command manually or using it through an alias works.\n\nWhen I switch '-S' with '--gpg-sign=NNN' everything works as it should \nfrom CMD Line - but not when I use for example SmartGit and enable 'Sign \nall Commits'. After countless hours looking through the Web, I am not \nout of Ideas.\n\nHere is the Trace:\nC:\\Dev\\GitRepos\\Test>git cm\n00:30:36.873133 exec-cmd.c:237      trace: resolved executable dir: \nC:/Dev/Git/mingw64/bin\n00:30:36.874133 git.c:744           trace: exec: git-cm\n00:30:36.874133 run-command.c:667   trace: run_command: git-cm\n00:30:36.876134 git.c:396           trace: alias expansion: cm => commit \n-S -s\n00:30:36.876134 git.c:805           trace: exec: git commit -S -s\n00:30:36.876134 run-command.c:667   trace: run_command: git commit -S -s\n00:30:36.883142 exec-cmd.c:237      trace: resolved executable dir: \nC:/Dev/Git/mingw64/libexec/git-core\n00:30:36.884143 git.c:455           trace: built-in: git commit -S -s\n\nhint: Waiting for your editor to close the file... 00:30:36.889147 \nrun-command.c:667       trace: run_command: GIT_INDEX_FILE=.git/index \n'\"C:/Dev/GitGuis/GitExtensions/GitExtensions.exe\" fileeditor' \nC:/Dev/GitRepos/Test/.git/COMMIT_EDITMSG\n00:30:45.064284 run-command.c:667       trace: run_command: 'C:\\Program \nFiles (x86)\\GnuPG\\bin\\gpg.exe' -bsau ''\ngpg: skipped \"\": Invalid user ID\ngpg: signing failed: Invalid user ID\nerror: gpg failed to sign the data\nfatal: failed to write commit object\n\nWindows: Windows 10 Pro, 21H1, 19043.1100\nGit Version: git version 2.32.0.windows.2\nGPG Version: gpg (GnuPG) 2.2.28, libgcrypt 1.8.8, Copyright (C) 2021 g10 \nCode GmbH\n\nThank you in advance!\nOliver Niebuhr\n"},{"id":"430983","messageId":"YPpqlnuGrk8Gunep@coredump.intra.peff.net","threadId":"56149","inReplyTo":"dfeebef5-6f48-082d-f49d-832863ff62a8@oliverniebuhr.de","subject":"Re: [Bug Report] Git does not push signingkey ID to GPG","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-07-23T07:07:02Z","receivedAt":"2021-07-23T07:07:05Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 23, 2021 at 01:42:20AM +0200, Oliver Niebuhr wrote:\n\n> I have edit the .gitconfig File accordingly and added\n> \n> [user]\n> signingkey = NNN\n> [commit]\n> gpgsign = true\n> [alias]\n> amend = commit -S -s --amend\n> cm = commit -S -s\n> commit = commit -S -s\n> tag = tag -S -s\n> [gpg]\n> program = C:\\\\Program Files (x86)\\\\GnuPG\\\\bin\\\\gpg.exe\n> \n> The Git User Name and eMail Address are the same which are set in the used\n> GPG Certificate.\n> \n> Using '-S' from the Windows CMD Shell and Git Bash leads to an error.\n> Neither typing the command manually or using it through an alias works.\n> \n> When I switch '-S' with '--gpg-sign=NNN' everything works as it should from\n> CMD Line - but not when I use for example SmartGit and enable 'Sign all\n> Commits'. After countless hours looking through the Web, I am not out of\n> Ideas.\n\nThis works fine for me. I get:\n\n  $ GIT_TRACE=1 git -c user.signingkey=1234abcd commit -S --amend --no-edit\n  03:03:26.487264 [pid=1285432] git.c:455           trace: built-in: git commit -S --amend --no-edit\n  03:03:26.491963 [pid=1285432] run-command.c:666   trace: run_command: gpg --status-fd=2 -bsau 1234abcd\n  error: gpg failed to sign the data\n  fatal: failed to write commit object\n\nIn your trace, the key parameter that's passed is the empty string:\n\n> 00:30:45.064284 run-command.c:667       trace: run_command: 'C:\\Program\n> Files (x86)\\GnuPG\\bin\\gpg.exe' -bsau ''\n> gpg: skipped \"\": Invalid user ID\n> gpg: signing failed: Invalid user ID\n\nYou showed config with user.signingkey set. Is it possible that you have\nother config (say, in the repo config file), that is taking precedence?\n\nWhat does:\n\n  git config --show-origin --get-all user.signingkey\n\nsay when run inside the repository?\n\n-Peff\n"}]}