Re: [PATCH v2 17/24] commit: use expected signature header for SHA-256
From: Junio C Hamano <hidden>
Date: 2020-02-24 18:24:46
"brian m. carlson" [off-list ref] writes:
quoted hunk
diff --git a/builtin/commit.c b/builtin/commit.c index 7ba33a3bec..798d362a2e 100644 --- a/builtin/commit.c +++ b/builtin/commit.c@@ -1659,7 +1659,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) } if (amend) { - const char *exclude_gpgsig[2] = { "gpgsig", NULL }; + const char *exclude_gpgsig[3] = { "gpgsig", "gpgsig-sha256", NULL };
For futureproofing, we should eventually revamp the machinery of read_commit_extra_headers() so that we do not have to maintain this array. Instead, the second parameter, that is passed down to read_commit_extra_header_lines() helper, should become a callback function that lets the caller say "no, I do not want this header", and we can use it to exclude "gpgsig", "gpgsig-sha256", and anything that begins with "gpgsig-" in the future. We might even want to exclude "gpgsig-$algo" where "$algo" is the name of the algorithm that this version of Git does not yet recognise while giving a warning, or perhaps we may want to cause read_commit_extra_headers() to yield an error on gpgsig with unknown hashalgo. These become easier to arrange with such a machinery update. One question I have is if it makes sense to do so now before this series, or we leave a "NEEDSWORK:" note and complete SHA-2 transition with the current mechanism.
+test_expect_success 'commit with multiple signatures is okay' ' + git cat-file commit HEAD >basis && + cat >sigs <<-EOF && + gpgsig -----BEGIN PGP SIGNATURE----- + VGhpcyBpcyBub3QgcmVhbGx5IGEgc2lnbmF0dXJlLg== + -----END PGP SIGNATURE----- + gpgsig-sha256 -----BEGIN PGP SIGNATURE----- + VGhpcyBpcyBub3QgcmVhbGx5IGEgc2lnbmF0dXJlLg== + -----END PGP SIGNATURE----- + EOF + sed -e "/^committer/q" basis >okay && + cat sigs >>okay && + echo >>okay && + sed -e "1,/^$/d" basis >>okay && + cat okay && + new=$(git hash-object -t commit -w --stdin <okay) && + test_when_finished "remove_object $new" && + git update-ref refs/heads/bogus "$new" && + test_when_finished "git update-ref -d refs/heads/bogus" && + git fsck 2>out && + cat out && + ! grep "commit $new" out +'
There seem to be a few debugging leftover cats in the above.