summaryrefslogtreecommitdiff
path: root/gpg-interface.c
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-10-22 16:38:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-22 23:00:43 (GMT)
commit4de9394dcb769394f490a0285015a1d26beb54d1 (patch)
treea52c37cadb29730f99005b9a68110619bcb2cd08 /gpg-interface.c
parent3daaaabe7ed22c17bff04d19c711be427bd2e225 (diff)
downloadgit-4de9394dcb769394f490a0285015a1d26beb54d1.zip
git-4de9394dcb769394f490a0285015a1d26beb54d1.tar.gz
git-4de9394dcb769394f490a0285015a1d26beb54d1.tar.bz2
gpg-interface.c: obtain primary key fingerprint as well
Obtain the primary key fingerprint off VALIDSIG status message, and expose it via %GP format. Signed-off-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index 1d33a7e..bea1aa2 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -74,6 +74,7 @@ void signature_check_clear(struct signature_check *sigc)
FREE_AND_NULL(sigc->signer);
FREE_AND_NULL(sigc->key);
FREE_AND_NULL(sigc->fingerprint);
+ FREE_AND_NULL(sigc->primary_key_fingerprint);
}
/* An exclusive status -- only one of them can appear in output */
@@ -108,7 +109,7 @@ static void parse_gpg_output(struct signature_check *sigc)
{
const char *buf = sigc->gpg_status;
const char *line, *next;
- int i;
+ int i, j;
int seen_exclusive_status = 0;
/* Iterate over all lines */
@@ -147,6 +148,18 @@ static void parse_gpg_output(struct signature_check *sigc)
next = strchrnul(line, ' ');
free(sigc->fingerprint);
sigc->fingerprint = xmemdupz(line, next - line);
+
+ /* Skip interim fields */
+ for (j = 9; j > 0; j--) {
+ if (!*next)
+ break;
+ line = next + 1;
+ next = strchrnul(line, ' ');
+ }
+
+ next = strchrnul(line, '\n');
+ free(sigc->primary_key_fingerprint);
+ sigc->primary_key_fingerprint = xmemdupz(line, next - line);
}
break;
@@ -165,6 +178,7 @@ found_duplicate_status:
*/
sigc->result = 'E';
/* Clear partial data to avoid confusion */
+ FREE_AND_NULL(sigc->primary_key_fingerprint);
FREE_AND_NULL(sigc->fingerprint);
FREE_AND_NULL(sigc->signer);
FREE_AND_NULL(sigc->key);