git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Patrick Steinhardt <ps@pks.im>, Elijah Newren <newren@gmail.com>,
	Jeff King <peff@peff.net>,
	"brian m . carlson" <sandals@crustytoothpaste.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Christian Couder <christian.couder@gmail.com>,
	Christian Couder <chriscool@tuxfamily.org>
Subject: [PATCH 1/3] fast-import: refactor finalize_commit_buffer()
Date: Wed,  5 Nov 2025 07:19:16 +0100	[thread overview]
Message-ID: <20251105061918.3688870-2-christian.couder@gmail.com> (raw)
In-Reply-To: <20251105061918.3688870-1-christian.couder@gmail.com>

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>
---
 builtin/fast-import.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 54d3e592c6..493de57ef6 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -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);
-- 
2.52.0.rc0.3.gf264cd25e5



  reply	other threads:[~2025-11-05  6:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05  6:19 [PATCH 0/3] fast-import: add 'strip-if-invalid' mode to --signed-commits=<mode> Christian Couder
2025-11-05  6:19 ` Christian Couder [this message]
2025-11-05  6:19 ` [PATCH 2/3] commit: refactor verify_commit_buffer() Christian Couder
2025-11-05  6:19 ` [PATCH 3/3] fast-import: add 'strip-if-invalid' mode to --signed-commits=<mode> Christian Couder
2025-11-08 18:32   ` Junio C Hamano
2025-11-12  7:25     ` Christian Couder
2025-11-12 16:51       ` Junio C Hamano
2025-11-05 14:40 ` [PATCH 0/3] " Junio C Hamano
2025-11-08  0:34   ` Elijah Newren
2025-11-12  7:22     ` Christian Couder
2025-11-12  7:19   ` Christian Couder
2025-11-12 16:51     ` Junio C Hamano
2025-11-17  4:34 ` [PATCH v2 " Christian Couder
2025-11-17  4:34   ` [PATCH v2 1/3] fast-import: refactor finalize_commit_buffer() Christian Couder
2025-11-17  4:34   ` [PATCH v2 2/3] commit: refactor verify_commit_buffer() Christian Couder
2025-11-17  4:34   ` [PATCH v2 3/3] fast-import: add 'strip-if-invalid' mode to --signed-commits=<mode> Christian Couder
2025-11-17 19:52   ` [PATCH v2 0/3] " Elijah Newren
2025-11-18 18:29     ` Christian Couder
2025-11-18 19:03       ` Junio C Hamano
2025-11-18 19:04       ` Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251105061918.3688870-2-christian.couder@gmail.com \
    --to=christian.couder@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).