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-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 8151A1F934 for ; Sun, 25 Oct 2020 22:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1420270AbgJYWly (ORCPT ); Sun, 25 Oct 2020 18:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1420265AbgJYWlw (ORCPT ); Sun, 25 Oct 2020 18:41:52 -0400 Received: from 0x63.nu (0x63.nu [IPv6:2a02:750:9::199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9B7C061755 for ; Sun, 25 Oct 2020 15:41:52 -0700 (PDT) Received: from ip6-localhost ([::1] helo=localhost.localdomain) by 0x63.nu with esmtp (Exim 4.90_1) (envelope-from ) id 1kWnXq-0007u5-U4; Sun, 25 Oct 2020 22:27:18 +0100 From: Anders Waldenborg To: git@vger.kernel.org Cc: Anders Waldenborg , christian.couder@gmail.com, peff@peff.net, jonathantanmy@google.com Subject: [PATCH 14/21] trailer: move skipping of blank lines to own loop when finding trailer Date: Sun, 25 Oct 2020 22:26:45 +0100 Message-Id: <20201025212652.3003036-15-anders@0x63.nu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201025212652.3003036-1-anders@0x63.nu> References: <20201025212652.3003036-1-anders@0x63.nu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: ::1 X-SA-Exim-Mail-From: anders@0x63.nu X-SA-Exim-Scanned: No (on st.localdomain) by 0x63.nu with esmtp (Exim 4.90_1) (envelope-from ) id 1kWnXq-0007u5-U4; Sun, 25 Oct 2020 22:27:18 +0100 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org ); SAEximRunCond expanded to false No functional change intended. Signed-off-by: Anders Waldenborg --- trailer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trailer.c b/trailer.c index 110d3ed226..937cf1edeb 100644 --- a/trailer.c +++ b/trailer.c @@ -829,7 +829,6 @@ static size_t find_trailer_start(const char *buf, size_t len) { const char *s; ssize_t end_of_title, l; - int only_spaces = 1; int recognized_prefix = 0, trailer_lines = 0, non_trailer_lines = 0; /* * Number of possible continuation lines encountered. This will be @@ -856,6 +855,12 @@ static size_t find_trailer_start(const char *buf, size_t len) * consists of at least 25% trailers. */ for (l = last_line(buf, len); + l >= end_of_title; + l = last_line(buf, l)) { + if (!is_blank_line(buf + l) && buf[l] != comment_line_char) + break; + } + for (; l >= end_of_title; l = last_line(buf, l)) { const char *bol = buf + l; @@ -868,8 +873,6 @@ static size_t find_trailer_start(const char *buf, size_t len) continue; } if (is_blank_line(bol)) { - if (only_spaces) - continue; non_trailer_lines += possible_continuation_lines; if (recognized_prefix && trailer_lines * 3 >= non_trailer_lines) @@ -878,7 +881,6 @@ static size_t find_trailer_start(const char *buf, size_t len) return next_line(bol) - buf; return len; } - only_spaces = 0; for (p = git_generated_prefixes; *p; p++) { if (starts_with(bol, *p)) { -- 2.25.1