From patchwork Mon Mar 10 15:57:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 14010372 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63F9D22E3F1 for ; Mon, 10 Mar 2025 15:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622287; cv=none; b=TM0QhgHRtrHy1Kck6GFEszHOBDjLJlK0AbInP4LcmF0z8TtqEWvAhuCMHCepceVpOO/a0uKFJ0p8V3ZBw7y2jYF48UYFq0Vp+M0K+3Cb1K5n1WJrBdFGtsoQHrQwS8+Bvv26jt3gXwukXcS7RnDJNJ5fZ66E/WUX+pnTAlhxYc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622287; c=relaxed/simple; bh=o5NRMLPLHeOZD8FhddB6YE4KFOYf+cJ+1gRKK5AqryY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p+gUInSiVaqMdJJZTCvvPhYI1h2vZ3dXdL9obzY9Plh0laWHwGbje8tZ8RoZyWdHT3cJvYmJy3DQgHYfVDLTKecdwuVBaI7A8fNRpHm45sgBz+Hgp47/oCFme892oL7JEtQQSsOEDLKEql9zBHVg42MpBBdNSbgQ9d4jeYvLJ2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZInpBn9d; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZInpBn9d" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-38f2f391864so2360884f8f.3 for ; Mon, 10 Mar 2025 08:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741622283; x=1742227083; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lgQxvMb9zHozk9PF4kDNdY9N0ZzWx/UlmwDfizoPze0=; b=ZInpBn9dom6EOjdaUrdgGEn0RRWMOkppIUo3a1ao1KVubm/fK1xNc6GhNhJJeb7CRi zJrzYh6EcCSshtSggVi3rGWgkt2Kg6R4mMetuuPuJagh2tdt9jPrmJgWtPwENoxqvMnA wm5FxGf8c7OxgXbJ40RWFtJ3wX0ooalR6JIKEX1FGlowhvBf+UUUGti4Jg+cqRD01OLZ 6zTDZB2XyPewUOso/Co/xd+QOGTyevfSlN83D2q9We7i8Ol9PRC1Sg900f37J36hyJcZ Hp1zzyMmweIMOaOPGC3Mv4DS0iVgI9mxLy72G0SI0K5FgkNY0Un24gUjc+xXXBPvs1eZ qkAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741622283; x=1742227083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lgQxvMb9zHozk9PF4kDNdY9N0ZzWx/UlmwDfizoPze0=; b=FXlLKclzvktX/AdvXlIpSzUynOsV3VwvMRYYCJNBr8p8nWD1vvRNng1jPTvtE/ldiA ocvK6N1Ujp9kJxvlcolouZNod3rwz7PHO8GL2XjE6jQLyEJOD2hpSpRVx4Pvwy3qN3Ny N5QHjxqgc1eHquVHaYnxvlx5G86cVZEugRUDoAKUlMS7bBigwutR1Zrn5U//bgnoJspI YcTKZ9/5tutQQVbnPO3U2Jp38+sYYTjAxACR6RJuE4RXK7u75Qpa2CTCSYovDTN23Tlh frV+Qcg62s0xox0yO7a4iStEqOYc/E3XauNn7z45NtU3mWut6xH1eX1TtjfLynjgfBai zV2Q== X-Gm-Message-State: AOJu0YyM58g3KsHBL43m7QFHlsYMBrE0as2QEhvgbWw+NoRDkNAR+pMx A9Q8PJ8M/C5l2S2ZnEJJ5Gu/m6iRwvbUMf1XZRnZOcEYX4YwyBM48JL3eg== X-Gm-Gg: ASbGnctp6sCLQnVoIUV+hEL91Psg4DCztbNaNt9aMlF0KEzOLTrmO5Oy8QA9kylwDL7 2qVLQ9Wqi/jRZhxAl+vNkrOzVtJ0M+PRTsOSwW2F1R44ZGpt4eUNcSlH8nbUeinviCr0OIrWJjm bUMhILE6fGB6zNDSyn2D2FyXPh+lG4GTu8qxgF9N3S1NvBMK3LVnYqe9ywcGdjqBKKX9XOWOy6w TqfLk305ApjySz6BlY284HGWt5TrKOtGjVjo+/t+DyXnApcY+2kt8KRMxzjf0916z/B5oKww5bi SPaL2keUqu60TuGkOPMv53T95CDYniWHBQfdc7nkhpoIe4Q7AwftTcKF11y27fqDseyZ8IOkyg5 PMSWcPWUQRyaC1LS3t5bdzu2zD3efUFdVv21OyQ== X-Google-Smtp-Source: AGHT+IEGzhRLEnhb1ukmZ6lX/RZDthW9S9erraYUcunDIqYTMIPwHfG+vXFw3/pgXqRS67UOOVD0Sw== X-Received: by 2002:a5d:6d8f:0:b0:391:6fd:bb64 with SMTP id ffacd0b85a97d-39132d1d1d6mr9375815f8f.13.1741622283077; Mon, 10 Mar 2025 08:58:03 -0700 (PDT) Received: from christian-Precision-5550.. (176-138-135-207.abo.bbox.fr. [176.138.135.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e4065sm15551831f8f.62.2025.03.10.08.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 08:58:02 -0700 (PDT) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Luke Shumaker , Elijah Newren , Jeff King , Johannes Schindelin , Taylor Blau , "brian m . carlson" , Eric Sunshine , Phillip Wood , Luke Shumaker , Christian Couder Subject: [PATCH v6 1/6] git-fast-import.adoc: add missing LF in the BNF Date: Mon, 10 Mar 2025 16:57:41 +0100 Message-ID: <20250310155746.879481-2-christian.couder@gmail.com> X-Mailer: git-send-email 2.49.0.rc1.89.g148d1db992 In-Reply-To: <20250310155746.879481-1-christian.couder@gmail.com> References: <20250224142744.279643-1-christian.couder@gmail.com> <20250310155746.879481-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luke Shumaker Signed-off-by: Luke Shumaker Signed-off-by: Christian Couder --- Documentation/git-fast-import.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc index 58a2eaa51a..8e0de618c0 100644 --- a/Documentation/git-fast-import.adoc +++ b/Documentation/git-fast-import.adoc @@ -437,7 +437,7 @@ change to the project. original-oid? ('author' (SP )? SP LT GT SP LF)? 'committer' (SP )? SP LT GT SP LF - ('encoding' SP )? + ('encoding' SP LF)? data ('from' SP LF)? ('merge' SP LF)* From patchwork Mon Mar 10 15:57:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 14010373 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B12B22FF53 for ; Mon, 10 Mar 2025 15:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622289; cv=none; b=WPaMrAJLALvXE6yv54YhL0pq8xs3C+69Na1hiwre62u8YwkqmXs+XJTEbcUJYVOkZwnMuj5lOkwWr8Qm9naNnpTgNEU3+UQDrDyat/MvDwKpIdWpYLEBOEh8ea8Bx5QLsf8RmJagz37f69Ra+QbRVN2uKrxBi7LIMlz5NWBB2Gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622289; c=relaxed/simple; bh=XhW+4pZ10Wf6fygk80cXJgLtc/YyPvj3YM5n0Wjw+hA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iOynljZSs1MbpIqrvajAD9Fo9uLfnyu2EJT0GT3qMuyKlI+Eqyjxi8xozpB2GnvfLdFHcC0Kv3wNLLe8TiGHi7y5lZT98bOs01Kzmpj300bX/z5Bfu5T8NnVivTShtKYCkTZDzDFeMRNee8Wk5Uxuu2j6bEX5YnG2UqWUjcgIZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g4j6VIeW; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g4j6VIeW" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-391211ea598so2501838f8f.1 for ; Mon, 10 Mar 2025 08:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741622285; x=1742227085; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oOhr4UxpC64RoNaCHeh9tu80BVzhUhITemkTc9ogq3E=; b=g4j6VIeWGFQx0A8DtNdhHCFftshXB7lo1eyob/T7a7IhMIrYJTxUGvVG0BfmWIYKU+ 9xBEFXMfZstw9xjocYwYK/z0Z4daynmnGGIhfZkZRbjYXzfIIcx3VHUNpZAgVYlQQ9uY HBl4RIyuaY1X6dObex9eaUR6ANWBLhinUzD/c2TkImb/V1C1rOUY/dhoqG1n+p/JFzyD b7V7Zui0c4Ihzyh6dW89pRJZpSBpT7nSNtiA4MPBt2Tv8qah+Rmu5P6HQfjWO13c9Khu D9Ekw3sF/IpD9kqx+Jwo2QPT8c0SivXypGHoYCJ4GOha1sEAdcWIDtxPopCB2O4Ga+Kg iUIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741622285; x=1742227085; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oOhr4UxpC64RoNaCHeh9tu80BVzhUhITemkTc9ogq3E=; b=jawxyzUrQH+zfMjljebBbYCUeRhyHuhMneGK7Ab493AFnYS8w9hkRG8L2JiPKR2tyn rDyR440hPI5EARLmUWBBgBnoLp1x9+LsJg79X/U3xR+Ay2BAQdBWV9p5vHxpCuZLNXkv qF8DNLp49xB+6bsNgiE2+3a6/POk00KTVn/A6pvQlwApujl6WWmHT8DrAOO/MpZjP5Sp uPFU3CBP9XMQo4TzDAV9bz3H/hqlkMhXUgh2qdDlaOjgNxXCB8Np312Ip6Zw+Iy6JeoW 3Zn2z60tZNtsyynZe4huxqsHstRojZd9c+ESkJ/Mhq/bHzpSEZnaL3bt5q39DOmu2KY/ Q/ew== X-Gm-Message-State: AOJu0YwAU0lhw+zK7+oY0uCPK/coWkgzaXwJMahfp+Pe52gVer4XIITc O9x5Ze4WUImWlL6DTehcj7CasnDpg1ccJsM2T2ieckoO73Ch5hR4n9Qk4g== X-Gm-Gg: ASbGncsfMN8uujOQ2uj/JjoNLSQ0b107HXosgItNWzwEWw9m+h69tDl8qorHPwjtc2p FnxF5i9rZj2qGO0KF+R+ElIGO8n/pCf3fwH4MzKY2Ec+k6WOmX8Q2/nL6NHZoDpepGBoJR4NUyf jQ7+yKCLKsXJBDXEU1by9/oFKBeQthrIzbvgJ+qQkryM/dC951dZ7U4qHrVTWAfjE9Hetbuj3jX jm+Hfv2INC8ukYJC/rIlXUneRBOVRgVTX+zE/8MYLdHDEGTGzogkpbhSfwxvZj0SnZYngok6eN8 UrPHbyCF8KnVZ0LAPPzuGUTB7qSF/m70D9TkepgvLOpHLvvGoy6Ni5L8HvVGhWhbLsMrWokPsT6 vm1y1WQgsrWeUJtvIy5b6APi4TB8= X-Google-Smtp-Source: AGHT+IE91qHGtAt+xg57GCDfAd13xmBA+E7y4ewEbaX2ByiTJ8eQq4IXz53lJkH11aBrXwOw37lP0w== X-Received: by 2002:adf:a1c7:0:b0:391:4095:49b7 with SMTP id ffacd0b85a97d-39140954a39mr4412952f8f.25.1741622284542; Mon, 10 Mar 2025 08:58:04 -0700 (PDT) Received: from christian-Precision-5550.. (176-138-135-207.abo.bbox.fr. [176.138.135.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e4065sm15551831f8f.62.2025.03.10.08.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 08:58:03 -0700 (PDT) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Luke Shumaker , Elijah Newren , Jeff King , Johannes Schindelin , Taylor Blau , "brian m . carlson" , Eric Sunshine , Phillip Wood , Christian Couder , Christian Couder Subject: [PATCH v6 2/6] fast-export: fix missing whitespace after switch Date: Mon, 10 Mar 2025 16:57:42 +0100 Message-ID: <20250310155746.879481-3-christian.couder@gmail.com> X-Mailer: git-send-email 2.49.0.rc1.89.g148d1db992 In-Reply-To: <20250310155746.879481-1-christian.couder@gmail.com> References: <20250224142744.279643-1-christian.couder@gmail.com> <20250310155746.879481-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 "Documentation/CodingGuidelines" says that there should be whitespaces around operators like 'if', 'switch', 'for', etc. Let's fix this in "builtin/fast-export.c". Signed-off-by: Christian Couder --- builtin/fast-export.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/fast-export.c b/builtin/fast-export.c index a5c82eef1d..2bf787191a 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -694,7 +694,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, if (anonymize) { reencoded = anonymize_commit_message(); } else if (encoding) { - switch(reencode_mode) { + switch (reencode_mode) { case REENCODE_YES: reencoded = reencode_string(message, "UTF-8", encoding); break; @@ -828,7 +828,7 @@ static void handle_tag(const char *name, struct tag *tag) const char *signature = strstr(message, "\n-----BEGIN PGP SIGNATURE-----\n"); if (signature) - switch(signed_tag_mode) { + switch (signed_tag_mode) { case SIGNED_TAG_ABORT: die("encountered signed tag %s; use " "--signed-tags= to handle it", @@ -853,7 +853,7 @@ static void handle_tag(const char *name, struct tag *tag) tagged = tag->tagged; tagged_mark = get_object_mark(tagged); if (!tagged_mark) { - switch(tag_of_filtered_mode) { + switch (tag_of_filtered_mode) { case TAG_FILTERING_ABORT: die("tag %s tags unexported object; use " "--tag-of-filtered-object= to handle it", @@ -965,7 +965,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info) continue; } - switch(commit->object.type) { + switch (commit->object.type) { case OBJ_COMMIT: break; case OBJ_BLOB: From patchwork Mon Mar 10 15:57:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 14010374 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D453822FF41 for ; Mon, 10 Mar 2025 15:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622291; cv=none; b=TeYY7kWnCHChP86bXQGdON09RJRApeyELjwN5PgTN4LIGBqwa+T3+v4rm5pXJ/0e2mFwCxwZAJuD93V6AwLJan98yFDVxoe3zPpSqAzyBlt8tQgXhWw1Z2j/qFREaR5E6pX4BSI3hkJNXBYvjNEVS56c3oe2l6MuewQfcZcWiBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622291; c=relaxed/simple; bh=larquBwQ0SyYXseLZG4+xV1xqpObrxz7cx75B5NB5p8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSNFcGXQnnoBe9YwHDBR/8LHeZPdj/oujWKqXm5snXFCSCf3ORjdi0o4rj+QW0R7LmUaerl1xsR96m087NUv4OBK+6bLW5Btcgar6gi/B9p3afhZYXgFyWUwwrIB8eGm9O3aijXWIw1eWkHw0uXiKP+sB7Q/zn7owNrcRzvB9Vc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z2y8siM0; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z2y8siM0" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-43bb6b0b898so37539275e9.1 for ; Mon, 10 Mar 2025 08:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741622287; x=1742227087; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ai8gJHBVUz2hoFs3uXh3eIcLrSBG9GBY77l8MfJu904=; b=Z2y8siM0GkFKN+bFaKF6yVcf0AV0EgGB42tGGkIWNUgxAbCeO2kfPwc+83LU2oKExO r2sa+tmdRell6WbBX1lDo2qf3Wr2Xb5LnHOA1ai4T21a7aAeOcTyUol2oyUvr2E7IQbp iPjzKu0sHM23axk56mReOpm21nbcAMZKj8p5FLtBatSTspx4+FKjXAhXo4tiH1ctaYvV ZhCUvRbFlP3mH34P21fQaO8O4d9Zh1YFaBySjXdTieLVcel2JACnMa2OTHEe/GtdqZ7y iSPabJgTTa9oOQQ833ATget4YrayaDImyqrfTUPbyEyo9ZrLor8BC/cuFTkw0G5q5lXh cX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741622287; x=1742227087; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ai8gJHBVUz2hoFs3uXh3eIcLrSBG9GBY77l8MfJu904=; b=rIS5behvnNV5UNaYu0iJ4YRG0wjIQ4hZQoM4URDS3GYWjUvhjZ4I5DOxLcnpD5TrbM Gn0ErzTHKw+FcFQ6PP7yPd8t+rf2ni6FMNz9199ZcbgpgB6F8B0/U5nY71qPM74bszwn ttyK3O80Q7jCvaK2bOP9LvXY24U2ehYTRD08NDmSaI+9/9pVSuHBg+mREALLfo5K4S99 ajPJOAqY9WTsgb+xtUb3cWmIhtqMxR6OKfuvBmxeQIdX4WsMFpjAdp+XxKXg01a45uMy M36i1mUHQCkfVYtmHr9Hr6wAb9NfJ0CbmW6BgYKpwj0z4QzdqhLN5VeRatlK36oIDvyv cYiA== X-Gm-Message-State: AOJu0YzpNKnxeXJ6+eqGaqMx4zBErrI9UnneCJDOq6zaDRIx1m88uRYR BYM+aT79Wp4AwETL9hd4d5XePJz89hUjsLsw6hwmqqa3JBiD1XitV8YXLw== X-Gm-Gg: ASbGncsyrG1/MF/cmarYirHZLuOP8cGMXXP7JnXzV+BypiBAxIQYT0QTatkKiGZBrO0 cPfi85MrrbnjLWnsjP6qfhd++lT8BFs18UxWcrbEkUDhnXttKGvnEmyBt5K9LXXaAAELuAhl5xk Zh71qzdFVkLKCbn9jvpkwwV/5ZWumAnsx8LfliCpaAvjHzhqpiMdCGfluyUCwYd+kvshJIQOly7 qXdwlY/S6zpPGUXRwHujS4FKchR4PQRQnqgEy+X0i217S/XCSI5SkS6jhJzy3VOnrvaB/Nn4dRO 7eOw91JHD+BAoV2NorIxApcNYgL5F1Sa9RC/Kn9vqz/z8qLiCDbSJ2i1WxN6nZTWRN/fElWqh7u bamY3nOvjUptXTay39nbKslgnDnc= X-Google-Smtp-Source: AGHT+IH7SGoTYMGlH52pQgbmzUS2RB5b0LyUX1YhpLCwl5cCaopIIIx7bEz4QZS8mnAqNLM1op5Bng== X-Received: by 2002:a5d:6dac:0:b0:38d:d0ca:fbad with SMTP id ffacd0b85a97d-392641bd284mr85708f8f.14.1741622286802; Mon, 10 Mar 2025 08:58:06 -0700 (PDT) Received: from christian-Precision-5550.. (176-138-135-207.abo.bbox.fr. [176.138.135.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e4065sm15551831f8f.62.2025.03.10.08.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 08:58:04 -0700 (PDT) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Luke Shumaker , Elijah Newren , Jeff King , Johannes Schindelin , Taylor Blau , "brian m . carlson" , Eric Sunshine , Phillip Wood , Luke Shumaker , Christian Couder Subject: [PATCH v6 3/6] fast-export: rename --signed-tags='warn' to 'warn-verbatim' Date: Mon, 10 Mar 2025 16:57:43 +0100 Message-ID: <20250310155746.879481-4-christian.couder@gmail.com> X-Mailer: git-send-email 2.49.0.rc1.89.g148d1db992 In-Reply-To: <20250310155746.879481-1-christian.couder@gmail.com> References: <20250224142744.279643-1-christian.couder@gmail.com> <20250310155746.879481-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luke Shumaker The --signed-tags= option takes one of five arguments specifying how to handle signed tags during export. Among these arguments, 'strip' is to 'warn-strip' as 'verbatim' is to 'warn' (the unmentioned argument is 'abort', which stops the fast-export process entirely). That is, signatures are either stripped or copied verbatim while exporting, with or without a warning. Match the pattern and rename 'warn' to 'warn-verbatim' to make it clear that it instructs fast-export to copy signatures verbatim. To maintain backwards compatibility, 'warn' is still recognized as deprecated synonym of 'warn-verbatim'. Signed-off-by: Luke Shumaker Signed-off-by: Christian Couder --- Documentation/git-fast-export.adoc | 6 +++--- builtin/fast-export.c | 8 ++++---- t/t9350-fast-export.sh | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Documentation/git-fast-export.adoc b/Documentation/git-fast-export.adoc index 752e4b9b01..ab9a315fa9 100644 --- a/Documentation/git-fast-export.adoc +++ b/Documentation/git-fast-export.adoc @@ -27,7 +27,7 @@ OPTIONS Insert 'progress' statements every objects, to be shown by 'git fast-import' during import. ---signed-tags=(verbatim|warn|warn-strip|strip|abort):: +--signed-tags=(verbatim|warn-verbatim|warn-strip|strip|abort):: Specify how to handle signed tags. Since any transformation after the export can change the tag names (which can also happen when excluding revisions) the signatures will not match. @@ -36,8 +36,8 @@ When asking to 'abort' (which is the default), this program will die when encountering a signed tag. With 'strip', the tags will silently be made unsigned, with 'warn-strip' they will be made unsigned but a warning will be displayed, with 'verbatim', they will be silently -exported and with 'warn', they will be exported, but you will see a -warning. +exported and with 'warn-verbatim' (or 'warn', a deprecated synonym), +they will be exported, but you will see a warning. --tag-of-filtered-object=(abort|drop|rewrite):: Specify how to handle tags whose tagged object is filtered out. diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 2bf787191a..2de2adc30e 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -36,7 +36,7 @@ static const char *fast_export_usage[] = { }; static int progress; -static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT; +static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN_VERBATIM, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT; static enum tag_of_filtered_mode { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT; static enum reencode_mode { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT; static int fake_missing_tagger; @@ -62,8 +62,8 @@ static int parse_opt_signed_tag_mode(const struct option *opt, *val = SIGNED_TAG_ABORT; else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore")) *val = VERBATIM; - else if (!strcmp(arg, "warn")) - *val = WARN; + else if (!strcmp(arg, "warn-verbatim") || !strcmp(arg, "warn")) + *val = WARN_VERBATIM; else if (!strcmp(arg, "warn-strip")) *val = WARN_STRIP; else if (!strcmp(arg, "strip")) @@ -833,7 +833,7 @@ static void handle_tag(const char *name, struct tag *tag) die("encountered signed tag %s; use " "--signed-tags= to handle it", oid_to_hex(&tag->object.oid)); - case WARN: + case WARN_VERBATIM: warning("exporting signed tag %s", oid_to_hex(&tag->object.oid)); /* fallthru */ diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 40427883ec..cc110727fb 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -253,6 +253,24 @@ test_expect_success 'signed-tags=verbatim' ' ' +test_expect_success 'signed-tags=warn-verbatim' ' + + git fast-export --signed-tags=warn-verbatim sign-your-name >output 2>err && + grep PGP output && + test -s err + +' + +# 'warn' is a backward-compatibility alias for 'warn-verbatim'; test +# that it keeps working. +test_expect_success 'signed-tags=warn' ' + + git fast-export --signed-tags=warn sign-your-name >output 2>err && + grep PGP output && + test -s err + +' + test_expect_success 'signed-tags=strip' ' git fast-export --signed-tags=strip sign-your-name > output && From patchwork Mon Mar 10 15:57:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 14010375 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 454BE2309B6 for ; Mon, 10 Mar 2025 15:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622294; cv=none; b=GO3cjE8y1VZl3dS4jYhlH5sIDbaIAJtXJPyDmWo6avC0vgtWv1Qmt6wx9RykHk7+hEepm/vPMAmSHxNotrKS8i0WKe8Qd3IexgqfgRewdUQnVKY9qVLTts9uc87YhPbTkUXXBdtzFy55r8/QfWpDdDysoVvQyHm4QSG1gm7DurQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622294; c=relaxed/simple; bh=2X7YFvFI7VW6GQeZVXANiquzJGbk31SWsHCz2ZXytAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qeHMzIFLc/8ZL2FBSCj1NIiIcZtax8RSM/gZazZX6mh9t+FVTo0XUYs/FQ1ryIlV+x/GQXFiwJPUJNYQOPZoh7pbLyN7d/wffwR0wk5QP80hLFWRAmkT/sPNSOD1ZrsQRZ9M9L2O3TBRksu04T5drHQdKmA3Yod/dG1bvn0gTY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YA+EXbLe; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YA+EXbLe" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4394a0c65fcso48204055e9.1 for ; Mon, 10 Mar 2025 08:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741622290; x=1742227090; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c1nATC23aNFFjw79hGB+599N1SNvtcyWml8/eV5YPXQ=; b=YA+EXbLe8SDfdNFmeX4RIoSW6vPjuaxrhgzi165iHyvntfo9sKEQ/vpCKhj3YztEzG sannkOPzKeFef5yBThlJpTjjuav0whvj7ISMk8S1FdCjXIL1nCaSaW3CJkmezB4N6iam sZz9nguE+MkmZgtx+0k8vu9jDq4caYEFuDuEoQ03UnA2Pqw27xv3nU0fPuwCEAm7KZmT CgAtjnJFDw2M06bsSlP1Z3ED2iG8SgaVFyMmPfj1dgsDE8d7i9I3w2/QcHQeXZT4feBd AlQMmurOL6v8d7zhkzVJ+DN69YH78jtpCIas5BlyhSgzPBbl5q8bcuDeM4ZIm4kF9xZr sGXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741622290; x=1742227090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c1nATC23aNFFjw79hGB+599N1SNvtcyWml8/eV5YPXQ=; b=GyXzSUuzselm5xauvgPGIoE6QEj2XVUMyNRLxXtH8ajUG/Yt4LFhxOl5IfetOfRTk8 Od72mrJqikCqYdaUovPviDqEwKj/OLPZpvBroYn7RQO7gJVsOXLOfaLgOg511wfoAbdz DQ+JBrkMES2RaWc8o7PqNd0z1IVMUrwQvgTglm+yT37MzBVuqEk8MHzoQmF4FpLmvq31 XXbI8T4Sv/N4wYWcJyyIxQ7iuD8unXVT+zDOxBc3LqYFORqtwFzPeuMKJgFAhzOJNZvy etmbBI9jjLdchqj8mcvyVVx3aE7gIYeKlsRodugsnqI5u2gqCPVNEyNFTqYpmw/n75jI SKaw== X-Gm-Message-State: AOJu0Yx0O8iAgl1jEKd7/GZNe+ZnsutGHKOvoJb/g76gE2HnZG8Gfeay 8rUKG7+i3jjcRo1pBlTiN9ta/VAkLTQnqXGV6ZMN468rAGIaYmOXFKaJAQ== X-Gm-Gg: ASbGncuYzV8wPQFam4aj0ikNIiIReOVvgYcZscXMvvy91grnHlnLDXdyjIAeLVcXmw+ ysQ4+reEQT+WQ0bOiFFpmXZarYX8rv+iARTPEKIVxCUco+vJ4GSWeatldbTZ/uo577HozWSqkBn XOSlfSy8Ww84fISoTi2djgA/jcvXMesgVOhkGk0CHBfvDOQvEwn17IrU46cRoHLDpzePef13aCs Kg6kSKZKb/nXl6bUJKxDYx4sjHcaQp1J9nY5L8Pfa+yD2D3HN2KNJABtfrSpZFJ2vrsOt5mvBrh k5LFo8FVVKMH0TsHNZErpccXnJrcA0violEgIcVtL1echuMnKioWolVqBCv0BB5QtnTv32H173h RDIZysy2D4CUWVMiBriJ/OQCHnvg= X-Google-Smtp-Source: AGHT+IHjDdjHdXGCVMXVf4Hn74O2Ro2vfSh0ch7j7XhF9jCLORx0NTCUF7HAB08cl2D64U/qEQXgeA== X-Received: by 2002:a05:600c:1553:b0:43c:ea36:9840 with SMTP id 5b1f17b1804b1-43cea36ccd7mr59919955e9.22.1741622287565; Mon, 10 Mar 2025 08:58:07 -0700 (PDT) Received: from christian-Precision-5550.. (176-138-135-207.abo.bbox.fr. [176.138.135.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e4065sm15551831f8f.62.2025.03.10.08.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 08:58:07 -0700 (PDT) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Luke Shumaker , Elijah Newren , Jeff King , Johannes Schindelin , Taylor Blau , "brian m . carlson" , Eric Sunshine , Phillip Wood , Luke Shumaker , Christian Couder Subject: [PATCH v6 4/6] git-fast-export.adoc: clarify why 'verbatim' may not be a good idea Date: Mon, 10 Mar 2025 16:57:44 +0100 Message-ID: <20250310155746.879481-5-christian.couder@gmail.com> X-Mailer: git-send-email 2.49.0.rc1.89.g148d1db992 In-Reply-To: <20250310155746.879481-1-christian.couder@gmail.com> References: <20250224142744.279643-1-christian.couder@gmail.com> <20250310155746.879481-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luke Shumaker Signed-off-by: Luke Shumaker Signed-off-by: Christian Couder --- Documentation/git-fast-export.adoc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/git-fast-export.adoc b/Documentation/git-fast-export.adoc index ab9a315fa9..2bb52261a0 100644 --- a/Documentation/git-fast-export.adoc +++ b/Documentation/git-fast-export.adoc @@ -29,15 +29,20 @@ OPTIONS --signed-tags=(verbatim|warn-verbatim|warn-strip|strip|abort):: Specify how to handle signed tags. Since any transformation - after the export can change the tag names (which can also happen - when excluding revisions) the signatures will not match. + after the export (or during the export, such as excluding + revisions) can change the hashes being signed, the signatures + may become invalid. + When asking to 'abort' (which is the default), this program will die when encountering a signed tag. With 'strip', the tags will silently be made unsigned, with 'warn-strip' they will be made unsigned but a warning will be displayed, with 'verbatim', they will be silently exported and with 'warn-verbatim' (or 'warn', a deprecated synonym), -they will be exported, but you will see a warning. +they will be exported, but you will see a warning. 'verbatim' and +'warn-verbatim' should only be used if you know that no transformation +affecting tags or any commit in their history will be performed by you +or by fast-export or fast-import, or if you do not care that the +resulting tag will have an invalid signature. --tag-of-filtered-object=(abort|drop|rewrite):: Specify how to handle tags whose tagged object is filtered out. From patchwork Mon Mar 10 15:57:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 14010376 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C04E230270 for ; Mon, 10 Mar 2025 15:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622294; cv=none; b=mYoGKrLOQ0pDmN6Sp4Jd0At+UX9xFj+XK5S4oB7LKXN10SgKlHkSPw9F0FvjxpHSXjz5kP1IEmL4VPP8sohikC5V4edTzyRfFaEIoEGS11m9Yq/0FPHm4/KYY9HeyJRD9pxWsvQUfKoyl18lO5TJGrZTV3QzurgqO+05yy8hrNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622294; c=relaxed/simple; bh=/Uf3aHnLbDv42g2MTgkrtC1GGEhQ/Dsgf138tTZHzG4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GddIZ86pJU+RixCIRdr7EX7sxE7Uqj9hX+bU6vny+ucThwgMOS0VGNZYHPxKry9yqBhaiXkA7hRyEjEO4JGhzremf2Cnu/887M/RKDP408CuXQfpOhQX5Pcpjq9nu+U4NqXQxO6jpKMcdYbMP9HJ5GZpm/8RXmT7Q6RZOjwpUX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WAQ6RFRT; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WAQ6RFRT" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-39129fc51f8so3694022f8f.0 for ; Mon, 10 Mar 2025 08:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741622290; x=1742227090; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4F3dU7xfOIjfpxs3SqWqvwYL7CEzDmAwL515cgL/3PU=; b=WAQ6RFRTEIT9Z7UBVZKt+CN7eY5wV4exfCBVev6KkUha4P54JEjTfAkOf3XQTGoFHk Uz1MzFJaTWYOqDuNGT4guN8FAEljPTqJrTiiVBH2w2C5PONTeMG72OFWwiM2RLjHBOQj ZuBD/ZVWTauq5iFSKWLdDUTMMaeoBkyaaoUw8XdjNeqwe5Qe0roPIEkivFNysSE5EWpv CWHZlG2kNJM46YYRtRcHJNiUB9ly5XzWkOS2S9dYgTls4Z0kQeYrMZEgOdM6ovgSCMzX 88FL4YfQ8DztsmqOlhTawTciw3zzxCm8NGFwT9ZbsOJ03VnmIdDGeCqGufg+ZLrHpV1q 6z/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741622290; x=1742227090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4F3dU7xfOIjfpxs3SqWqvwYL7CEzDmAwL515cgL/3PU=; b=edr/zFf1SCGwSp7EVTsDRktJLGMtYEd9p1xfSN3c7rBaEg55QG/f0pqMhfLH5CoL1q Z/OhxnPpY9iCCTfgqVkG5HvTahnAjUNJ7d4Zvv7YUoJlmtNiVyTJ771nXAe9xUjby2aH R2y3Lg9KbeLbEbOtYyO+L7ufi2PU/RDmA4JLP00HuQobpPmPPsmde2OudVQ2Uf+Lwr+d bJgSZm93sOITji1+Sg22LmbJhNa31ck0XvUxNWdeBTSC2Pg7iyZnYRFJpSR8mtWLylYy 2ffU20rOBy9bqBlQTYie6ERgqG/WYGpGgF+cPemwp6ac+Ld4QPTXsRFchPW9JiApMkDb WDkw== X-Gm-Message-State: AOJu0YyrpMn2IMtehiw/CncFIrtaUseV+oltnA+3/LqHZFmxeTfrRjja IMZCLpZtLD9pw4ZF39I8vAzo+aqLMxfgSR/35uzxdLGn/olIRpPiQBi13Q== X-Gm-Gg: ASbGncvmQiPJzpTpNECTBuqn7o695bZ6CWlHPZCcQSQuJJFWUNqvn+heXj/88Rv5b4z tfw4TQ6uz9feadmc/9SOzNSQ2sgugMm4xFrTE6SXq03tB7BN4k5Z7EbMgwsC8qpS6pUAo/stQMT z9VaPdleJftAyHCtOzllKCcsJqm/yGOs9olWPnvOcfCYXeYEguvpDQN7PPuOL+SkDIrMrR0PUt6 hXHR00vuo92mVFUh2/4HH//uMRgsMCZq5A5EIKIfm8z0RJJdXtB35QzPlM2jM2BosEfLk8lX1oq PRKoMErqsNuteHt4CY3JGWcJs8HymcwTvtLWzb5i0P2BAULzIZ5eGsJvOavkQiQ1HSqRB+P9sBr /Ku4BYPOdWSJzw+9tD4JfAlU+2FA= X-Google-Smtp-Source: AGHT+IHhP+LFnlLUTS9WxQVucxZ0OHQcShxKxtXYldMm5FkkQRmoPZkbwAxQVXl8wdIGY00gptFy1w== X-Received: by 2002:adf:a31d:0:b0:391:38a5:efa with SMTP id ffacd0b85a97d-39138a51108mr5947978f8f.23.1741622289059; Mon, 10 Mar 2025 08:58:09 -0700 (PDT) Received: from christian-Precision-5550.. (176-138-135-207.abo.bbox.fr. [176.138.135.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e4065sm15551831f8f.62.2025.03.10.08.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 08:58:07 -0700 (PDT) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Luke Shumaker , Elijah Newren , Jeff King , Johannes Schindelin , Taylor Blau , "brian m . carlson" , Eric Sunshine , Phillip Wood , Luke Shumaker , Christian Couder Subject: [PATCH v6 5/6] fast-export: do not modify memory from get_commit_buffer Date: Mon, 10 Mar 2025 16:57:45 +0100 Message-ID: <20250310155746.879481-6-christian.couder@gmail.com> X-Mailer: git-send-email 2.49.0.rc1.89.g148d1db992 In-Reply-To: <20250310155746.879481-1-christian.couder@gmail.com> References: <20250224142744.279643-1-christian.couder@gmail.com> <20250310155746.879481-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luke Shumaker fast-export's helper function find_encoding() takes a `const char *`, but modifies that memory despite the `const`. Ultimately, this memory came from get_commit_buffer(), and you're not supposed to modify the memory that you get from get_commit_buffer(). So, get rid of find_encoding() in favor of commit.h:find_commit_header(), which gives back a string length, rather than mutating the memory to insert a '\0' terminator. Because find_commit_header() detects the "\n\n" string that separates the headers and the commit message, move the call to be above the `message = strstr(..., "\n\n")` call. This helps readability, and allows for the value of `encoding` to be used for a better value of "..." so that the same memory doesn't need to be checked twice. Introduce a `commit_buffer_cursor` variable to avoid writing an awkward `encoding ? encoding + encoding_len : committer_end` expression. Signed-off-by: Luke Shumaker Signed-off-by: Christian Couder --- builtin/fast-export.c | 61 +++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 2de2adc30e..39d43c2a29 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -510,21 +510,6 @@ static void show_filemodify(struct diff_queue_struct *q, } } -static const char *find_encoding(const char *begin, const char *end) -{ - const char *needle = "\nencoding "; - char *bol, *eol; - - bol = memmem(begin, end ? end - begin : strlen(begin), - needle, strlen(needle)); - if (!bol) - return NULL; - bol += strlen(needle); - eol = strchrnul(bol, '\n'); - *eol = '\0'; - return bol; -} - static char *anonymize_ref_component(void) { static int counter; @@ -630,9 +615,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, struct string_list *paths_of_changed_objects) { int saved_output_format = rev->diffopt.output_format; - const char *commit_buffer; + const char *commit_buffer, *commit_buffer_cursor; const char *author, *author_end, *committer, *committer_end; - const char *encoding, *message; + const char *encoding = NULL; + size_t encoding_len; + const char *message; char *reencoded = NULL; struct commit_list *p; const char *refname; @@ -641,21 +628,35 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, rev->diffopt.output_format = DIFF_FORMAT_CALLBACK; parse_commit_or_die(commit); - commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL); - author = strstr(commit_buffer, "\nauthor "); + commit_buffer_cursor = commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL); + + author = strstr(commit_buffer_cursor, "\nauthor "); if (!author) die("could not find author in commit %s", oid_to_hex(&commit->object.oid)); author++; - author_end = strchrnul(author, '\n'); - committer = strstr(author_end, "\ncommitter "); + commit_buffer_cursor = author_end = strchrnul(author, '\n'); + + committer = strstr(commit_buffer_cursor, "\ncommitter "); if (!committer) die("could not find committer in commit %s", oid_to_hex(&commit->object.oid)); committer++; - committer_end = strchrnul(committer, '\n'); - message = strstr(committer_end, "\n\n"); - encoding = find_encoding(committer_end, message); + commit_buffer_cursor = committer_end = strchrnul(committer, '\n'); + + /* + * find_commit_header() gets a `+ 1` because + * commit_buffer_cursor points at the trailing "\n" at the end + * of the previous line, but find_commit_header() wants a + * pointer to the beginning of the next line. + */ + if (*commit_buffer_cursor == '\n') { + encoding = find_commit_header(commit_buffer_cursor + 1, "encoding", &encoding_len); + if (encoding) + commit_buffer_cursor = encoding + encoding_len; + } + + message = strstr(commit_buffer_cursor, "\n\n"); if (message) message += 2; @@ -694,16 +695,20 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, if (anonymize) { reencoded = anonymize_commit_message(); } else if (encoding) { + char *buf; switch (reencode_mode) { case REENCODE_YES: - reencoded = reencode_string(message, "UTF-8", encoding); + buf = xstrfmt("%.*s", (int)encoding_len, encoding); + reencoded = reencode_string(message, "UTF-8", buf); + free(buf); break; case REENCODE_NO: break; case REENCODE_ABORT: - die("Encountered commit-specific encoding %s in commit " + die("Encountered commit-specific encoding %.*s in commit " "%s; use --reencode=[yes|no] to handle it", - encoding, oid_to_hex(&commit->object.oid)); + (int)encoding_len, encoding, + oid_to_hex(&commit->object.oid)); } } if (!commit->parents) @@ -715,7 +720,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, (int)(author_end - author), author, (int)(committer_end - committer), committer); if (!reencoded && encoding) - printf("encoding %s\n", encoding); + printf("encoding %.*s\n", (int)encoding_len, encoding); printf("data %u\n%s", (unsigned)(reencoded ? strlen(reencoded) : message From patchwork Mon Mar 10 15:57:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 14010377 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5172222E415 for ; Mon, 10 Mar 2025 15:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622295; cv=none; b=pfO/r5w+2Qwr53lNrttLHMPtdwe9kORzT2FuXT11JyrD7GQYw+LkiqGpMQUcbEfevMTwwc9sxrQnKMW6lx3YTO+sOg3PYQk01Wa/GXlAbzuM4pX94EwNGTLv+ZFTm+4uXM8cFzZ1E1QblwPoq/nd/cxnrKGToCW3M0qzPNhbM6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741622295; c=relaxed/simple; bh=Rr8l6aAyNlSZm4fCpWL9wOIuuWeWUc5MoPp0m5UMeeU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DPIxKMMLxlpzYppXFp7BWXzGua01GM/zTIhMm8hn75z8dFXSSAT8EVcWLECtpwlCt+2Xan+9PBss0WIpKLVeGEEOZh0h835fgQ6zpo0U/bq3deBisXa2KR4OxCaNiqGXFXJLBSgZfoUMmQPivyB/a21CqAtZAfmSrlODfdXEr/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AXnDGCuU; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AXnDGCuU" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43cf848528aso9967685e9.2 for ; Mon, 10 Mar 2025 08:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741622290; x=1742227090; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tGwBWOQe3C32hsFrUC22MWPghIdI9fz/VwkWsghhZbk=; b=AXnDGCuUJ9jGikWMKOgSWV6mF2BRuxQNgQD6PaxPIDFQdE6nINwIiI88WkaEbxvY7L 9S7LMbGPXRX5P5c3cpeToy0UlAouyFhxPu4XBYmlo8TWlguMy5a7K3n4JlJCU8VJyGCa mU5DIVPzj56SO6iaSzjxHuvtOmOpvV6RkBlKshA6A5/FKfbFr3iCHQlV7kApXLv7XmmH 1kY1QaFRGSWe+W44TOvNN3+Ord7b120XcWd6X0E1AwuzIck1VJy0POz3xD6SmV3u0m5n /G5shBMNu/pLKdHTCVv/Lu5PC94KRiCvwm3Oljm/OLtx68D9lqkBRRpIDabmvgx23itM uEoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741622290; x=1742227090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tGwBWOQe3C32hsFrUC22MWPghIdI9fz/VwkWsghhZbk=; b=Owm5vsvW5LnLNUeVoKGYydKK+Wf6Or3sOKz4Etm+S6BaNmqmwCmG6sLHacP9LFZqas nhMgLKBeMyr3HFkr12Q3JFZXRPa/upAiS+WihEfoQ2QDHYLiyxLndTI3ZAOsWAMyoLBN qGQEVS0k8dCjnIU3t7UfmmhO8N89WU0TC02VTm5KUca83/g5sDV99vWapDnDMXdmLlXc 4mBnqvxsz8XVhXDtuNRa1cqer+V9B8enz8DXRFBQiPNXD0HTOtFkPH/s4PvxATcoDFDx gobgdHYdLERPIy1OPdIkeihWFS2YzmM7Jqg4JQSRAZi/MMVdRx+6G6QvkpTxv92Dgcql uPUw== X-Gm-Message-State: AOJu0YyM55J+iwV4vgE8sT5JGZh+9SaRIBFmTBYMTBjCJ47CCx3Mwfyn Aisg0lEhRZ3yjeSXwIX4tRWcpMSWq6TwJXdrrNaHqW4+8/UYjWBhquVF3g== X-Gm-Gg: ASbGncsYea4DnE2oG5arbNRHGqeYanlPS6908SjZXJ2txvVJeGa0fNkx8xuduZQJiVE bDA0OYQs+HSZ8+Ai9TI3gsQGR02ult6qcVoXKXbSB+Xidk4MgcMhV4IiLBhBTTIZRkP5aej5jMo /gTPM7UnGR8Z2/WPgoBfU1WaT6Nq/Z1tpw7Ki4zXXfqFBDckjWTnm3S/Z501dQn93DDSriTHj/l xAQIGHprBmm8AOsS1+mFeRALh9XB4y323YBqxgLgj3L4d9u/wSkbGTi+WiFwU8z32ncEQ2WfcKA mo4Awp/R6y65OMsRaubKE102vfl9nU8yQamGC3lCV8hdgM7Roil65rct1ejaU7HFdzv94TpcAY/ 8kSI8oR7tQzbDhX8TKXrHXbmVLqk+K11AcWVykQ== X-Google-Smtp-Source: AGHT+IHoEHz1fkQ/t0eDaFTSr9r44kBmZ5Rspd6yR/BFxlfs2BnhzypdHhOW6EL3Zx1BzD7tmKls/g== X-Received: by 2002:a05:600c:3111:b0:43c:f7b8:83c7 with SMTP id 5b1f17b1804b1-43d01c22322mr1201465e9.25.1741622290108; Mon, 10 Mar 2025 08:58:10 -0700 (PDT) Received: from christian-Precision-5550.. (176-138-135-207.abo.bbox.fr. [176.138.135.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e4065sm15551831f8f.62.2025.03.10.08.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 08:58:09 -0700 (PDT) From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Luke Shumaker , Elijah Newren , Jeff King , Johannes Schindelin , Taylor Blau , "brian m . carlson" , Eric Sunshine , Phillip Wood , Luke Shumaker , Christian Couder Subject: [PATCH v6 6/6] fast-export, fast-import: add support for signed-commits Date: Mon, 10 Mar 2025 16:57:46 +0100 Message-ID: <20250310155746.879481-7-christian.couder@gmail.com> X-Mailer: git-send-email 2.49.0.rc1.89.g148d1db992 In-Reply-To: <20250310155746.879481-1-christian.couder@gmail.com> References: <20250224142744.279643-1-christian.couder@gmail.com> <20250310155746.879481-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luke Shumaker fast-export has a --signed-tags= option that controls how to handle tag signatures. However, there is no equivalent for commit signatures; it just silently strips the signature out of the commit (analogously to --signed-tags=strip). While signatures are generally problematic for fast-export/fast-import (because hashes are likely to change), if they're going to support tag signatures, there's no reason to not also support commit signatures. So, implement a --signed-commits= option that mirrors the --signed-tags= option. On the fast-export side, try to be as much like signed-tags as possible, in both implementation and in user-interface. This will change the default behavior to '--signed-commits=abort' from what is now '--signed-commits=strip'. In order to provide an escape hatch for users of third-party tools that call fast-export and do not yet know of the --signed-commits= option, add an environment variable 'FAST_EXPORT_SIGNED_COMMITS_NOABORT=1' that changes the default to '--signed-commits=warn-strip'. Signed-off-by: Luke Shumaker Signed-off-by: Christian Couder --- Documentation/git-fast-export.adoc | 11 +++ Documentation/git-fast-import.adoc | 18 +++++ builtin/fast-export.c | 123 ++++++++++++++++++++++++----- builtin/fast-import.c | 23 ++++++ t/t9350-fast-export.sh | 98 +++++++++++++++++++++++ 5 files changed, 253 insertions(+), 20 deletions(-) diff --git a/Documentation/git-fast-export.adoc b/Documentation/git-fast-export.adoc index 2bb52261a0..413a527496 100644 --- a/Documentation/git-fast-export.adoc +++ b/Documentation/git-fast-export.adoc @@ -44,6 +44,17 @@ affecting tags or any commit in their history will be performed by you or by fast-export or fast-import, or if you do not care that the resulting tag will have an invalid signature. +--signed-commits=(verbatim|warn-verbatim|warn-strip|strip|abort):: + Specify how to handle signed commits. Behaves exactly as + '--signed-tags', but for commits. Default is 'abort'. ++ +Earlier versions this command that did not have '--signed-commits' +behaved as if '--signed-commits=strip'. As an escape hatch for users +of tools that call 'git fast-export' but do not yet support +'--signed-commits', you may set the environment variable +'FAST_EXPORT_SIGNED_COMMITS_NOABORT=1' in order to change the default +from 'abort' to 'warn-strip'. + --tag-of-filtered-object=(abort|drop|rewrite):: Specify how to handle tags whose tagged object is filtered out. Since revisions and files to export can be limited by path, diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc index 8e0de618c0..7b107f5e8e 100644 --- a/Documentation/git-fast-import.adoc +++ b/Documentation/git-fast-import.adoc @@ -431,12 +431,21 @@ and control the current import process. More detailed discussion Create or update a branch with a new commit, recording one logical change to the project. +//// +Yes, it's intentional that the 'gpgsig' line doesn't have a trailing +`LF`; the definition of `data` has a byte-count prefix, so it +doesn't need an `LF` to act as a terminator (and `data` also already +includes an optional trailing `LF?` just in case you want to include +one). +//// + .... 'commit' SP LF mark? original-oid? ('author' (SP )? SP LT GT SP LF)? 'committer' (SP )? SP LT GT SP LF + ('gpgsig' SP LF data)? ('encoding' SP LF)? data ('from' SP LF)? @@ -505,6 +514,15 @@ that was selected by the --date-format= command-line option. See ``Date Formats'' above for the set of supported formats, and their syntax. +`gpgsig` +^^^^^^^^ + +The optional `gpgsig` command is used to include a PGP/GPG signature +that signs the commit data. + +Here specifies which hashing algorithm is used for this +signature, either `sha1` or `sha256`. + `encoding` ^^^^^^^^^^ The optional `encoding` command indicates the encoding of the commit diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 39d43c2a29..126980f724 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -35,8 +35,11 @@ static const char *fast_export_usage[] = { NULL }; +enum sign_mode { SIGN_ABORT, SIGN_VERBATIM, SIGN_STRIP, SIGN_WARN_VERBATIM, SIGN_WARN_STRIP }; + static int progress; -static enum signed_tag_mode { SIGNED_TAG_ABORT, VERBATIM, WARN_VERBATIM, WARN_STRIP, STRIP } signed_tag_mode = SIGNED_TAG_ABORT; +static enum sign_mode signed_tag_mode = SIGN_ABORT; +static enum sign_mode signed_commit_mode = SIGN_ABORT; static enum tag_of_filtered_mode { TAG_FILTERING_ABORT, DROP, REWRITE } tag_of_filtered_mode = TAG_FILTERING_ABORT; static enum reencode_mode { REENCODE_ABORT, REENCODE_YES, REENCODE_NO } reencode_mode = REENCODE_ABORT; static int fake_missing_tagger; @@ -53,23 +56,24 @@ static int anonymize; static struct hashmap anonymized_seeds; static struct revision_sources revision_sources; -static int parse_opt_signed_tag_mode(const struct option *opt, +static int parse_opt_sign_mode(const struct option *opt, const char *arg, int unset) { - enum signed_tag_mode *val = opt->value; - - if (unset || !strcmp(arg, "abort")) - *val = SIGNED_TAG_ABORT; + enum sign_mode *val = opt->value; + if (unset) + return 0; + else if (!strcmp(arg, "abort")) + *val = SIGN_ABORT; else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore")) - *val = VERBATIM; + *val = SIGN_VERBATIM; else if (!strcmp(arg, "warn-verbatim") || !strcmp(arg, "warn")) - *val = WARN_VERBATIM; + *val = SIGN_WARN_VERBATIM; else if (!strcmp(arg, "warn-strip")) - *val = WARN_STRIP; + *val = SIGN_WARN_STRIP; else if (!strcmp(arg, "strip")) - *val = STRIP; + *val = SIGN_STRIP; else - return error("Unknown signed-tags mode: %s", arg); + return error("Unknown %s mode: %s", opt->long_name, arg); return 0; } @@ -611,6 +615,43 @@ static void anonymize_ident_line(const char **beg, const char **end) *end = out->buf + out->len; } +/* + * find_commit_multiline_header is similar to find_commit_header, + * except that it handles multi-line headers, rather than simply + * returning the first line of the header. + * + * The returned string has had the ' ' line continuation markers + * removed, and points to allocated memory that must be free()d (not + * to memory within 'msg'). + * + * If the header is found, then *end is set to point at the '\n' in + * msg that immediately follows the header value. + */ +static const char *find_commit_multiline_header(const char *msg, + const char *key, + const char **end) +{ + struct strbuf val = STRBUF_INIT; + const char *bol, *eol; + size_t len; + + bol = find_commit_header(msg, key, &len); + if (!bol) + return NULL; + eol = bol + len; + strbuf_add(&val, bol, len); + + while (eol[0] == '\n' && eol[1] == ' ') { + bol = eol + 2; + eol = strchrnul(bol, '\n'); + strbuf_addch(&val, '\n'); + strbuf_add(&val, bol, eol - bol); + } + + *end = eol; + return strbuf_detach(&val, NULL); +} + static void handle_commit(struct commit *commit, struct rev_info *rev, struct string_list *paths_of_changed_objects) { @@ -619,6 +660,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, const char *author, *author_end, *committer, *committer_end; const char *encoding = NULL; size_t encoding_len; + const char *signature_alg = NULL, *signature = NULL; const char *message; char *reencoded = NULL; struct commit_list *p; @@ -645,17 +687,25 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, commit_buffer_cursor = committer_end = strchrnul(committer, '\n'); /* - * find_commit_header() gets a `+ 1` because - * commit_buffer_cursor points at the trailing "\n" at the end - * of the previous line, but find_commit_header() wants a + * find_commit_header() and find_commit_multiline_header() get + * a `+ 1` because commit_buffer_cursor points at the trailing + * "\n" at the end of the previous line, but they want a * pointer to the beginning of the next line. */ + if (*commit_buffer_cursor == '\n') { encoding = find_commit_header(commit_buffer_cursor + 1, "encoding", &encoding_len); if (encoding) commit_buffer_cursor = encoding + encoding_len; } + if (*commit_buffer_cursor == '\n') { + if ((signature = find_commit_multiline_header(commit_buffer_cursor + 1, "gpgsig", &commit_buffer_cursor))) + signature_alg = "sha1"; + else if ((signature = find_commit_multiline_header(commit_buffer_cursor + 1, "gpgsig-sha256", &commit_buffer_cursor))) + signature_alg = "sha256"; + } + message = strstr(commit_buffer_cursor, "\n\n"); if (message) message += 2; @@ -719,6 +769,31 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, printf("%.*s\n%.*s\n", (int)(author_end - author), author, (int)(committer_end - committer), committer); + if (signature) { + switch (signed_commit_mode) { + case SIGN_ABORT: + die("encountered signed commit %s; use " + "--signed-commits= to handle it", + oid_to_hex(&commit->object.oid)); + case SIGN_WARN_VERBATIM: + warning("exporting signed commit %s", + oid_to_hex(&commit->object.oid)); + /* fallthru */ + case SIGN_VERBATIM: + printf("gpgsig %s\ndata %u\n%s", + signature_alg, + (unsigned)strlen(signature), + signature); + break; + case SIGN_WARN_STRIP: + warning("stripping signature from commit %s", + oid_to_hex(&commit->object.oid)); + /* fallthru */ + case SIGN_STRIP: + break; + } + free((char *)signature); + } if (!reencoded && encoding) printf("encoding %.*s\n", (int)encoding_len, encoding); printf("data %u\n%s", @@ -834,21 +909,21 @@ static void handle_tag(const char *name, struct tag *tag) "\n-----BEGIN PGP SIGNATURE-----\n"); if (signature) switch (signed_tag_mode) { - case SIGNED_TAG_ABORT: + case SIGN_ABORT: die("encountered signed tag %s; use " "--signed-tags= to handle it", oid_to_hex(&tag->object.oid)); - case WARN_VERBATIM: + case SIGN_WARN_VERBATIM: warning("exporting signed tag %s", oid_to_hex(&tag->object.oid)); /* fallthru */ - case VERBATIM: + case SIGN_VERBATIM: break; - case WARN_STRIP: + case SIGN_WARN_STRIP: warning("stripping signature from tag %s", oid_to_hex(&tag->object.oid)); /* fallthru */ - case STRIP: + case SIGN_STRIP: message_size = signature + 1 - message; break; } @@ -1194,6 +1269,7 @@ int cmd_fast_export(int argc, const char *prefix, struct repository *repo UNUSED) { + const char *env_signed_commits_noabort; struct rev_info revs; struct commit *commit; char *export_filename = NULL, @@ -1207,7 +1283,10 @@ int cmd_fast_export(int argc, N_("show progress after objects")), OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, N_("mode"), N_("select handling of signed tags"), - parse_opt_signed_tag_mode), + parse_opt_sign_mode), + OPT_CALLBACK(0, "signed-commits", &signed_commit_mode, N_("mode"), + N_("select handling of signed commits"), + parse_opt_sign_mode), OPT_CALLBACK(0, "tag-of-filtered-object", &tag_of_filtered_mode, N_("mode"), N_("select handling of tags that tag filtered objects"), parse_opt_tag_of_filtered_mode), @@ -1248,6 +1327,10 @@ int cmd_fast_export(int argc, if (argc == 1) usage_with_options (fast_export_usage, options); + env_signed_commits_noabort = getenv("FAST_EXPORT_SIGNED_COMMITS_NOABORT"); + if (env_signed_commits_noabort && *env_signed_commits_noabort) + signed_commit_mode = SIGN_WARN_STRIP; + /* we handle encodings */ git_config(git_default_config, NULL); diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 397a6f46ad..e432e8d5a1 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -2719,10 +2719,13 @@ static struct hash_list *parse_merge(unsigned int *count) static void parse_new_commit(const char *arg) { + static struct strbuf sig = STRBUF_INIT; static struct strbuf msg = STRBUF_INIT; + struct string_list siglines = STRING_LIST_INIT_NODUP; struct branch *b; char *author = NULL; char *committer = NULL; + char *sig_alg = NULL; char *encoding = NULL; struct hash_list *merge_list = NULL; unsigned int merge_count; @@ -2746,6 +2749,13 @@ static void parse_new_commit(const char *arg) } if (!committer) die("Expected committer but didn't get one"); + if (skip_prefix(command_buf.buf, "gpgsig ", &v)) { + sig_alg = xstrdup(v); + read_next_command(); + parse_data(&sig, 0, NULL); + read_next_command(); + } else + strbuf_setlen(&sig, 0); if (skip_prefix(command_buf.buf, "encoding ", &v)) { encoding = xstrdup(v); read_next_command(); @@ -2819,10 +2829,23 @@ static void parse_new_commit(const char *arg) strbuf_addf(&new_data, "encoding %s\n", encoding); + if (sig_alg) { + if (!strcmp(sig_alg, "sha1")) + strbuf_addstr(&new_data, "gpgsig "); + else if (!strcmp(sig_alg, "sha256")) + strbuf_addstr(&new_data, "gpgsig-sha256 "); + else + die("Expected gpgsig algorithm sha1 or sha256, got %s", sig_alg); + string_list_split_in_place(&siglines, sig.buf, "\n", -1); + strbuf_add_separated_string_list(&new_data, "\n ", &siglines); + strbuf_addch(&new_data, '\n'); + } strbuf_addch(&new_data, '\n'); strbuf_addbuf(&new_data, &msg); + string_list_clear(&siglines, 1); free(author); free(committer); + free(sig_alg); free(encoding); if (!store_object(OBJ_COMMIT, &new_data, NULL, &b->oid, next_mark)) diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index cc110727fb..304bac5b1d 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -8,6 +8,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh +. "$TEST_DIRECTORY/lib-gpg.sh" test_expect_success 'setup' ' @@ -284,10 +285,107 @@ test_expect_success 'signed-tags=warn-strip' ' test -s err ' +test_expect_success GPG 'set up signed commit' ' + + # Generate a commit with both "gpgsig" and "encoding" set, so + # that we can test that fast-import gets the ordering correct + # between the two. + test_config i18n.commitEncoding ISO-8859-1 && + git checkout -f -b commit-signing main && + echo Sign your name >file-sign && + git add file-sign && + git commit -S -m "signed commit" && + COMMIT_SIGNING=$(git rev-parse --verify commit-signing) + +' + +test_expect_success GPG 'signed-commits default' ' + + sane_unset FAST_EXPORT_SIGNED_COMMITS_NOABORT && + test_must_fail git fast-export --reencode=no commit-signing && + + FAST_EXPORT_SIGNED_COMMITS_NOABORT=1 git fast-export --reencode=no commit-signing >output 2>err && + ! grep ^gpgsig output && + grep "^encoding ISO-8859-1" output && + test -s err && + sed "s/commit-signing/commit-strip-signing/" output | ( + cd new && + git fast-import && + STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) && + test $COMMIT_SIGNING != $STRIPPED + ) + +' + +test_expect_success GPG 'signed-commits=abort' ' + + test_must_fail git fast-export --signed-commits=abort commit-signing + +' + +test_expect_success GPG 'signed-commits=verbatim' ' + + git fast-export --signed-commits=verbatim --reencode=no commit-signing >output && + grep "^gpgsig sha" output && + grep "encoding ISO-8859-1" output && + ( + cd new && + git fast-import && + STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) && + test $COMMIT_SIGNING = $STRIPPED + ) output 2>err && + grep "^gpgsig sha" output && + grep "encoding ISO-8859-1" output && + test -s err && + ( + cd new && + git fast-import && + STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) && + test $COMMIT_SIGNING = $STRIPPED + ) output && + ! grep ^gpgsig output && + grep "^encoding ISO-8859-1" output && + sed "s/commit-signing/commit-strip-signing/" output | ( + cd new && + git fast-import && + STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) && + test $COMMIT_SIGNING != $STRIPPED + ) + +' + +test_expect_success GPG 'signed-commits=warn-strip' ' + + git fast-export --signed-commits=warn-strip --reencode=no commit-signing >output 2>err && + ! grep ^gpgsig output && + grep "^encoding ISO-8859-1" output && + test -s err && + sed "s/commit-signing/commit-strip-signing/" output | ( + cd new && + git fast-import && + STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) && + test $COMMIT_SIGNING != $STRIPPED + ) + +' + test_expect_success 'setup submodule' ' test_config_global protocol.file.allow always && git checkout -f main && + test_might_fail git update-ref -d refs/heads/commit-signing && mkdir sub && ( cd sub &&