# Calling "gpg --sign" with loopback pinentry in some scenarios, but not always

2 messages from 2024-02-17 to 2024-02-17. Participants: Jens Schmidt, Junio C Hamano.
Thread: https://gitlist.dev/t/60942

## Jens Schmidt, 2024-02-17 22:51

Subject: Calling "gpg --sign" with loopback pinentry in some scenarios, but not always
Message-ID: <de38341b-f69f-4d3b-a4c2-4443e1ec1f6f@vodafonemail.de>
URL: https://gitlist.dev/e/de38341b-f69f-4d3b-a4c2-4443e1ec1f6f%40vodafonemail.de

```
Hi.

I'd like to use gpg loopback pinentry mode when signing commits
or tags through Emacs/Magit but default, non-loopback pinentry
for all other cases.

In particular, configuring "pinentry-mode loopback" in "gpg.conf"
is not really an option for me.

It seems that "git" does not have any hooks to pass arbitrary
additional parameters to "gpg", right?  So my only reasonable
option would be a Emacs/Magit-specific "gpg"-wrapper that adds
command line parameter "--pinentry-mode loopback" to the wrapped
"gpg" executable.

Any other options?

Thanks!

```

## Junio C Hamano, 2024-02-17 23:31

Subject: Re: Calling "gpg --sign" with loopback pinentry in some scenarios, but not always
Message-ID: <xmqqle7ifz2i.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqle7ifz2i.fsf%40gitster.g
In-Reply-To: <de38341b-f69f-4d3b-a4c2-4443e1ec1f6f@vodafonemail.de>

```
Jens Schmidt <farblos@vodafonemail.de> writes:

> It seems that "git" does not have any hooks to pass arbitrary
> additional parameters to "gpg", right?  So my only reasonable
> option would be a Emacs/Magit-specific "gpg"-wrapper that adds
> command line parameter "--pinentry-mode loopback" to the wrapped
> "gpg" executable.

Correct.  You can point your gpg.program configuration variable at
your wrapper, perhaps

    $ cat >"$HOME/bin/mygpg-with-pinentry" <<\EOF
    #!/bin/sh
    exec gpg --pinentry-mode loopback "$@"
    EOF
    $ chmod +x "$HOME/bin/mygpg-with-pinentry"
    $ git config gpg.openpgp.program "$HOME/bin/mygpg-with-pinentry"

or something like that.  It is unfortunate that

    $ git config gpg.openpgp.program "gpg --pinentry-mode loopback"

does not work.

```
