Subject: Re: Problem signing a tag

From: Michael J Gruber <[email-masked]>
Date: Thu, 05 Nov 2009 09:29:24 +0100

Joshua J. Kugler venit, vidit, dixit 04.11.2009 19:47:
> On Wednesday 04 November 2009, Michael J Gruber said something like:
>>> gpg: problem with the agent - disabling agent use
>>> error: gpg failed to sign the tag
>>> error: unable to sign the tag
>>> $ echo $?
>>> 128
>>>
>>> And when I sign at the prompt:
>>>
>>> $ gpg -sa
>>>
>>> You need a passphrase to unlock the secret key for
>>> user: "Joshua J. Kugler <[email-masked]>"
>>> 1024-bit DSA key, ID 14EA086E, created 2009-08-09
>>>
>>> gpg: problem with the agent - disabling agent use
>>> Blah blah blah blah
>>> Blah blah blah blah
>>> $ echo $?
>>> 2
>>
>> [...]
>>
>> I assume you don't want to use gpg-agent, that should be the easy way
>> out.
> 
> Well, I could, but I just haven't set it up. :)
> 
>> If that helps you can put "--no-use-agent" in your gpg config.
> 
> I commented out use-agent in the config. That worked. THANKS!
> 
>> 2 is a non-fatal error, 128 a fatal one, btw.
> 
> Well, the 2 was from running gpg alone, and 128 was from git erroring 
> out.  According to the gpg docs:
> 
> "The program returns 0 if everything was fine, 1 if at least a signature 
> was bad, and other error codes for fatal errors."
> 
> So, the docs consider 2 a fatal error, even though it appears it isn't.  
> It seems that 
> http://github.com/git/git/blob/a6dbf8814f433a7fbfa9cde6333c98019f6db1e4/builtin-tag.c#L202 
> needs to be patched to something along the lines of:
> 
> rv = finish_command(&gpg)
> if ((rv && rv !=2)  || !len || len < 0)
> 
> Probably digging in to the gpg source code to figure out what errors are 
> and aren't fatal would be in order.
> 
> Thanks again for your help! Glad to know what I needed to do to sign my 
> tags!

Dig dig dig... gpg exits with 2 in a lot of cases, one would need to
parse fd-error to find out more. But it also looks as if gpg exits
normally with a good passphrase. So I tried, and at least with gpg 1.4.9
and git 1.6.5.2 I can sign tags with "use-agent" and without a running
agent: I get asked for the passphrase (after reporting the agent MIA),
and everything's fine.

My gpg returns 0 in this case; it returns 2 only if I don't enter the
passphrase. So, this seems to depend on the version of gpg. Or on
entering the correct passphrase ;)

Michael