From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 548EF1F8C6 for ; Tue, 13 Jul 2021 00:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233793AbhGMAiR (ORCPT ); Mon, 12 Jul 2021 20:38:17 -0400 Received: from cloud.peff.net ([104.130.231.41]:47350 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbhGMAiR (ORCPT ); Mon, 12 Jul 2021 20:38:17 -0400 Received: (qmail 25808 invoked by uid 109); 13 Jul 2021 00:35:28 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 13 Jul 2021 00:35:28 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 3974 invoked by uid 111); 13 Jul 2021 00:35:27 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Mon, 12 Jul 2021 20:35:27 -0400 Authentication-Results: peff.net; auth=none Date: Mon, 12 Jul 2021 20:35:25 -0400 From: Jeff King To: Luca Weiss Cc: git@vger.kernel.org Subject: Re: git interpret-trailers: behavior with input without trailing newline Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, Jul 08, 2021 at 10:33:46AM +0000, Luca Weiss wrote: > I'm investigating a behavior with git interpret-trailers where when > the input does not end with a newline, git appends the trailer > directly without a newline; and on running the same command again it > doesn't detect the previous trailer anymore. > > I've whipped up a quick PoC in form of a new test case in the existing > test cases of git. In general, I think commit message inputs should have trailing newlines, as they'd generally be coming from actual commits, or piped through git-stripspace to clean things up. That said, the behavior you're seeing does seem like a bug to me. I don't think it was intended, and it would be nice to fix it, if you're up for it. It might be as simple as conditionally adding a newline after we read the input in trailers.c:read_input_file(). (IMHO even if we do not end up adding a trailer, normalizing the whitespace in this way would be a fine behavior for the command). -Peff