<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/t7510-signed-commit.sh, branch v2.45.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.45.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.45.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-06-06T00:32:12Z</updated>
<entry>
<title>t/lib-gpg: introduce new prereq GPG2</title>
<updated>2023-06-06T00:32:12Z</updated>
<author>
<name>Kousik Sanagavarapu</name>
<email>five231003@gmail.com</email>
</author>
<published>2023-06-04T18:22:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2f36339fa8622ee1cba957e8d0ef15719c697de3'/>
<id>urn:sha1:2f36339fa8622ee1cba957e8d0ef15719c697de3</id>
<content type='text'>
GnuPG v2.0.0 released in 2006, which according to its release notes

	https://gnupg.org/download/release_notes.html

is the "First stable version of GnuPG integrating OpenPGP and S/MIME".

Use this version or its successors for tests that will fail for
versions less than v2.0.0 because of the difference in the output on
stderr between the versions (v2.* vs v0.* or v2.* vs v1.*). Skip if
the GPG version detected is less than v2.0.0.

Do not, however, remove the existing prereq GPG yet since a lot of tests
still work with the prereq GPG (that is even with versions v0.* or v1.*)
and some systems still use these versions.

Mentored-by: Christian Couder &lt;christian.couder@gmail.com&gt;
Mentored-by: Hariom Verma &lt;hariom18599@gmail.com&gt;
Signed-off-by: Kousik Sanagavarapu &lt;five231003@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface: set trust level of missing key to "undefined"</title>
<updated>2023-04-19T15:30:54Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-04-19T01:29:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7891e465856e539c4a102dadec6dca9ac51c38df'/>
<id>urn:sha1:7891e465856e539c4a102dadec6dca9ac51c38df</id>
<content type='text'>
In check_signature(), we initialize the trust_level field to "-1", with
the idea that if gpg does not return a trust level at all (if there is
no signature, or if the signature is made by an unknown key), we'll
use that value. But this has two problems:

  1. Since the field is an enum, it's up to the compiler to decide what
     underlying storage to use, and it only has to fit the values we've
     declared. So we may not be able to store "-1" at all. And indeed,
     on my system (linux with gcc), the resulting enum is an unsigned
     32-bit value, and -1 becomes 4294967295.

     The difference may seem academic (and you even get "-1" if you pass
     it to printf("%d")), but it means that code like this:

       status |= sigc-&gt;trust_level &lt; configured_min_trust_level;

     does not necessarily behave as expected. This turns out not to be a
     bug in practice, though, because we keep the "-1" only when gpg did
     not report a signature from a known key, in which case the line
     above:

       status |= sigc-&gt;result != 'G';

     would always set status to non-zero anyway. So only a 'G' signature
     with no parsed trust level would cause a problem, which doesn't
     seem likely to trigger (outside of unexpected gpg behavior).

  2. When using the "%GT" format placeholder, we pass the value to
     gpg_trust_level_to_str(), which complains that the value is out of
     range with a BUG(). This behavior was introduced by 803978da49
     (gpg-interface: add function for converting trust level to string,
     2022-07-11). Before that, we just did a switch() on the enum, and
     anything that wasn't matched would end up as the empty string.

     Curiously, solving this by naively doing:

       if (level &lt; 0)
               return "";

     in that function isn't sufficient. Because of (1) above, the
     compiler can (and does in my case) actually remove that conditional
     as dead code!

We can solve both by representing this state as an enum value. We could
do this by adding a new "unknown" value. But this really seems to match
the existing "undefined" level well. GPG describes this as "Not enough
information for calculation".

We have tests in t7510 that trigger this case (verifying a signature
from a key that we don't have, and then checking various %G
placeholders), but they didn't notice the BUG() because we didn't look
at %GT for that case! Let's make sure we check all %G placeholders for
each case in the formatting tests.

The interesting ones here are "show unknown signature with custom
format" and "show lack of signature with custom format", both of which
would BUG() before, and now turn %GT into "undefined". Prior to
803978da49 they would have turned it into the empty string, but I think
saying "undefined" consistently is a reasonable outcome, and probably
makes life easier for anyone parsing the output (and any such parser had
to be ready to see "undefined" already).

The other modified tests produce the same output before and after this
patch, but now we're consistently checking both %G? and %GT in all of
them.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Reported-by: Rolf Eike Beer &lt;eb@emlix.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/gpg-errors'</title>
<updated>2023-02-24T19:32:29Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-02-24T19:32:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=38a227b796653d61a21d9b31e44e48dd66f647e0'/>
<id>urn:sha1:38a227b796653d61a21d9b31e44e48dd66f647e0</id>
<content type='text'>
Error messages given upon a signature verification failure used to
discard the errors from underlying gpg program, which has been
corrected.

* js/gpg-errors:
  gpg: do show gpg's error message upon failure
  t7510: add a test case that does not need gpg
</content>
</entry>
<entry>
<title>gpg: do show gpg's error message upon failure</title>
<updated>2023-02-15T16:55:24Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2023-02-15T05:58:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ad6b320756d8d9150291c696a02c86d1c2f0f4b2'/>
<id>urn:sha1:ad6b320756d8d9150291c696a02c86d1c2f0f4b2</id>
<content type='text'>
There are few things more frustrating when signing a commit fails than
reading a terse "error: gpg failed to sign the data" message followed by
the unsurprising "fatal: failed to write commit object" message.

In many cases where signing a commit or tag fails, `gpg` actually said
something helpful, on its stderr, and Git even consumed that, but then
keeps mum about it.

Teach Git to stop withholding that rather important information.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t7510: add a test case that does not need gpg</title>
<updated>2023-02-15T16:55:22Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2023-02-15T05:58:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8300d15d5ecea1e41b2b1d381238ccaaec501dd4'/>
<id>urn:sha1:8300d15d5ecea1e41b2b1d381238ccaaec501dd4</id>
<content type='text'>
This test case not only increases test coverage in setups without
working gpg, but also prepares for verifying that the error message of
`gpg.program` is shown upon failure.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t: use hash-object --literally when created malformed objects</title>
<updated>2023-01-18T20:59:44Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-01-18T20:41:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=34959d80db602b7d6893c9e2dfa81d78fd16f702'/>
<id>urn:sha1:34959d80db602b7d6893c9e2dfa81d78fd16f702</id>
<content type='text'>
Many test scripts use hash-object to create malformed objects to see how
we handle the results in various commands. In some cases we already have
to use "hash-object --literally", because it does some rudimentary
quality checks. But let's use "--literally" more consistently to
future-proof these tests against hash-object learning to be more
careful.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'fs/gpg-unknown-key-test-fix'</title>
<updated>2022-01-12T23:11:42Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-12T23:11:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=83ca08298e2b31b8b0528abab33d8472d2b7b8df'/>
<id>urn:sha1:83ca08298e2b31b8b0528abab33d8472d2b7b8df</id>
<content type='text'>
Test simplification.

* fs/gpg-unknown-key-test-fix:
  t/gpg: simplify test for unknown key
</content>
</entry>
<entry>
<title>t/gpg: simplify test for unknown key</title>
<updated>2022-01-12T19:21:22Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2022-01-12T12:07:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0517f591ca290a14ee3e516e478e8d2b78b45822'/>
<id>urn:sha1:0517f591ca290a14ee3e516e478e8d2b78b45822</id>
<content type='text'>
To test for a key that is completely unknown to the keyring we need one
to sign the commit with. This was done by generating a new key and not
add it into the keyring. To avoid the key generation overhead and
problems where GPG did hang in CI during it, switch GNUPGHOME to the
empty $GNUPGHOME_NOT_USED instead, therefore making all used keys unknown
for this single `verify-commit` call.

Reported-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Reviewed-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ssh signing: make sign/amend test more resilient</title>
<updated>2021-11-19T17:05:27Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2021-11-19T15:07:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3b4b5a793a36d1e92114ff929eb7d15d55d45a96'/>
<id>urn:sha1:3b4b5a793a36d1e92114ff929eb7d15d55d45a96</id>
<content type='text'>
The test `amending already signed commit` is using git checkout to
select a specific commit to amend. In case an earlier test fails and
leaves behind a dirty index/worktree this test would fail as well.
Using `checkout -f` will avoid interference by most other tests.

Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ssh signing: test that gpg fails for unknown keys</title>
<updated>2021-09-10T21:15:53Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2021-09-10T20:07:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1bfb57f642d34dc4b65be3602bb429abd9f32b58'/>
<id>urn:sha1:1bfb57f642d34dc4b65be3602bb429abd9f32b58</id>
<content type='text'>
Test that verify-commit/tag will fail when a gpg key is completely
unknown. To do this we have to generate a key, use it for a signature
and delete it from our keyring aferwards completely.

Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
