mirror of
https://github.com/git/git.git
synced 2026-01-08 09:13:48 +00:00
fast-import: refactor finalize_commit_buffer()
In a following commit we are going to finalize commit buffers with or without signatures in order to check the signatures and possibly drop them. To do so easily and without duplication, let's refactor the current code that finalizes commit buffers into a new finalize_commit_buffer() function. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
4cf919bd7b
commit
388517c14c
@@ -2815,6 +2815,18 @@ static void import_one_signature(struct signature_data *sig_sha1,
|
||||
die(_("parse_one_signature() returned unknown hash algo"));
|
||||
}
|
||||
|
||||
static void finalize_commit_buffer(struct strbuf *new_data,
|
||||
struct signature_data *sig_sha1,
|
||||
struct signature_data *sig_sha256,
|
||||
struct strbuf *msg)
|
||||
{
|
||||
add_gpgsig_to_commit(new_data, "gpgsig ", sig_sha1);
|
||||
add_gpgsig_to_commit(new_data, "gpgsig-sha256 ", sig_sha256);
|
||||
|
||||
strbuf_addch(new_data, '\n');
|
||||
strbuf_addbuf(new_data, msg);
|
||||
}
|
||||
|
||||
static void parse_new_commit(const char *arg)
|
||||
{
|
||||
static struct strbuf msg = STRBUF_INIT;
|
||||
@@ -2950,11 +2962,8 @@ static void parse_new_commit(const char *arg)
|
||||
"encoding %s\n",
|
||||
encoding);
|
||||
|
||||
add_gpgsig_to_commit(&new_data, "gpgsig ", &sig_sha1);
|
||||
add_gpgsig_to_commit(&new_data, "gpgsig-sha256 ", &sig_sha256);
|
||||
finalize_commit_buffer(&new_data, &sig_sha1, &sig_sha256, &msg);
|
||||
|
||||
strbuf_addch(&new_data, '\n');
|
||||
strbuf_addbuf(&new_data, &msg);
|
||||
free(author);
|
||||
free(committer);
|
||||
free(encoding);
|
||||
|
||||
Reference in New Issue
Block a user