From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21E40C433B4 for ; Tue, 20 Apr 2021 16:23:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9A5161003 for ; Tue, 20 Apr 2021 16:23:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233158AbhDTQYQ (ORCPT ); Tue, 20 Apr 2021 12:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233210AbhDTQYN (ORCPT ); Tue, 20 Apr 2021 12:24:13 -0400 Received: from mav.lukeshu.com (mav.lukeshu.com [IPv6:2001:19f0:5c00:8069:5400:ff:fe26:6a86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66CA4C06174A for ; Tue, 20 Apr 2021 09:23:41 -0700 (PDT) Received: from lukeshu-dw-thinkpad (unknown [8.42.69.49]) by mav.lukeshu.com (Postfix) with ESMTPSA id 1EAD880590; Tue, 20 Apr 2021 12:23:40 -0400 (EDT) Date: Tue, 20 Apr 2021 10:23:39 -0600 Message-ID: <87v98gq60k.wl-lukeshu@lukeshu.com> From: Luke Shumaker To: Taylor Blau Cc: Luke Shumaker , git@vger.kernel.org, Luke Shumaker , Junio C Hamano , Elijah Newren , Jeff King , Johannes Schindelin , =?UTF-8?B?Tmd1eeG7hW4g?= =?ISO-8859-1?Q?Th?= =?ISO-8859-1?Q?=E1i_?= =?UTF-8?B?Tmfhu41j?= Duy Subject: Re: [PATCH 3/3] fast-export, fast-import: implement signed-commits In-Reply-To: References: <20210419225441.3139048-1-lukeshu@lukeshu.com> <20210419225441.3139048-4-lukeshu@lukeshu.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, 19 Apr 2021 19:45:46 -0600, Taylor Blau wrote: > > diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt > > index d4a2bfe037..6fdb678b54 100644 > > --- a/Documentation/git-fast-export.txt > > +++ b/Documentation/git-fast-export.txt > > @@ -39,6 +39,18 @@ warning will be displayed, with 'verbatim', they will be silently > > exported and with 'warn-verbatim', they will be exported, but you will > > see a warning. > > > > +--signed-commits=(verbatim|warn-verbatim|warn-strip|strip|abort):: > > + Specify how to handle signed commits. Since any transformation > > + after the export can change the commit (which can also happen > > + when excluding revisions) the signatures will not match. > > ++ > > +When asking to 'abort', this program will die when encountering a > > +signed commit. With 'strip' (which is the default), the commits 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', they will be exported, > > +but you will see a warning. > > + > > OK, this all seems normal to me. But it may be worth shortening it to > say "behaves exactly as --signed-tags, but for commits", or something. Good suggestion, it would also make it more obvious that the default is different, since I'd have to call it out explictly. > > --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.txt b/Documentation/git-fast-import.txt > > index 458af0a2d6..3d0c5dbf7d 100644 > > --- a/Documentation/git-fast-import.txt > > +++ b/Documentation/git-fast-import.txt > > @@ -437,6 +437,7 @@ change to the project. > > original-oid? > > ('author' (SP )? SP LT GT SP LF)? > > 'committer' (SP )? SP LT GT SP LF > > + ('gpgsig' LF data)? > > Is this missing a LF after data? No, the definition of `data` has a byte-count prefix, so it doesn't need an `LF` to act as a terminator (and it also already includes an optional trailing `LF?` just in case you want to include one). In fact, my implementation in fast-export does not include the LF, which is why the test greps for "encoding ISO-8859-1" instead of "^encoding ISO-8859-1". I'll add a comment saying that it's intentional. > > +static const char *find_signature(const char *begin, const char *end) > > +{ > > + const char *needle = "\ngpgsig "; > > + char *bod, *eod, *eol; > > + > > + bod = memmem(begin, end ? end - begin : strlen(begin), > > + needle, strlen(needle)); > > + if (!bod) > > + return NULL; > > + bod += strlen(needle); > > + eod = strchrnul(bod, '\n'); > > + while (eod[0] == '\n' && eod[1] == ' ') { > > + eod = strchrnul(eod+1, '\n'); > > + } > > + *eod = '\0'; > > + > > + while ((eol = strstr(bod, "\n "))) > > + memmove(eol+1, eol+2, strlen(eol+1)); > > Hmm. I'm not quite sure I follow these last two lines. Perhaps a comment > would help? The rest of this patch looks reasonable to me. In the commit object, multi-line header values are stored by prefixing continuation lines begin with a space. So within the commit object, it looks like "gpgsig -----BEGIN PGP SIGNATURE-----\n" " Version: GnuPG v1.4.5 (GNU/Linux)\n" " \n" " base64_pem_here\n" " -----END PGP SIGNATURE-----\n" However, we want the raw value; we want to return "-----BEGIN PGP SIGNATURE-----\n" "Version: GnuPG v1.4.5 (GNU/Linux)\n" "\n" "base64_pem_here\n" "-----END PGP SIGNATURE-----\n" without all the extra spaces. That's what those two lines are doing, stripping out the extra spaces. I'll add some comments. -- Happy hacking, ~ Luke Shumaker