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>
This commit is contained in:
parent
3daaaabe7e
commit
4de9394dcb
@ -154,6 +154,8 @@ endif::git-rev-list[]
|
|||||||
- '%GS': show the name of the signer for a signed commit
|
- '%GS': show the name of the signer for a signed commit
|
||||||
- '%GK': show the key used to sign a signed commit
|
- '%GK': show the key used to sign a signed commit
|
||||||
- '%GF': show the fingerprint of the key used to sign a signed commit
|
- '%GF': show the fingerprint of the key used to sign a signed commit
|
||||||
|
- '%GP': show the fingerprint of the primary key whose subkey was used
|
||||||
|
to sign a signed commit
|
||||||
- '%gD': reflog selector, e.g., `refs/stash@{1}` or
|
- '%gD': reflog selector, e.g., `refs/stash@{1}` or
|
||||||
`refs/stash@{2 minutes ago`}; the format follows the rules described
|
`refs/stash@{2 minutes ago`}; the format follows the rules described
|
||||||
for the `-g` option. The portion before the `@` is the refname as
|
for the `-g` option. The portion before the `@` is the refname as
|
||||||
|
@ -74,6 +74,7 @@ void signature_check_clear(struct signature_check *sigc)
|
|||||||
FREE_AND_NULL(sigc->signer);
|
FREE_AND_NULL(sigc->signer);
|
||||||
FREE_AND_NULL(sigc->key);
|
FREE_AND_NULL(sigc->key);
|
||||||
FREE_AND_NULL(sigc->fingerprint);
|
FREE_AND_NULL(sigc->fingerprint);
|
||||||
|
FREE_AND_NULL(sigc->primary_key_fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An exclusive status -- only one of them can appear in output */
|
/* 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 *buf = sigc->gpg_status;
|
||||||
const char *line, *next;
|
const char *line, *next;
|
||||||
int i;
|
int i, j;
|
||||||
int seen_exclusive_status = 0;
|
int seen_exclusive_status = 0;
|
||||||
|
|
||||||
/* Iterate over all lines */
|
/* Iterate over all lines */
|
||||||
@ -147,6 +148,18 @@ static void parse_gpg_output(struct signature_check *sigc)
|
|||||||
next = strchrnul(line, ' ');
|
next = strchrnul(line, ' ');
|
||||||
free(sigc->fingerprint);
|
free(sigc->fingerprint);
|
||||||
sigc->fingerprint = xmemdupz(line, next - line);
|
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;
|
break;
|
||||||
@ -165,6 +178,7 @@ found_duplicate_status:
|
|||||||
*/
|
*/
|
||||||
sigc->result = 'E';
|
sigc->result = 'E';
|
||||||
/* Clear partial data to avoid confusion */
|
/* Clear partial data to avoid confusion */
|
||||||
|
FREE_AND_NULL(sigc->primary_key_fingerprint);
|
||||||
FREE_AND_NULL(sigc->fingerprint);
|
FREE_AND_NULL(sigc->fingerprint);
|
||||||
FREE_AND_NULL(sigc->signer);
|
FREE_AND_NULL(sigc->signer);
|
||||||
FREE_AND_NULL(sigc->key);
|
FREE_AND_NULL(sigc->key);
|
||||||
|
@ -24,6 +24,7 @@ struct signature_check {
|
|||||||
char *signer;
|
char *signer;
|
||||||
char *key;
|
char *key;
|
||||||
char *fingerprint;
|
char *fingerprint;
|
||||||
|
char *primary_key_fingerprint;
|
||||||
};
|
};
|
||||||
|
|
||||||
void signature_check_clear(struct signature_check *sigc);
|
void signature_check_clear(struct signature_check *sigc);
|
||||||
|
4
pretty.c
4
pretty.c
@ -1260,6 +1260,10 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
|||||||
if (c->signature_check.fingerprint)
|
if (c->signature_check.fingerprint)
|
||||||
strbuf_addstr(sb, c->signature_check.fingerprint);
|
strbuf_addstr(sb, c->signature_check.fingerprint);
|
||||||
break;
|
break;
|
||||||
|
case 'P':
|
||||||
|
if (c->signature_check.primary_key_fingerprint)
|
||||||
|
strbuf_addstr(sb, c->signature_check.primary_key_fingerprint);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user